Error 401: "Unauthorized" "invalid oauth token" when requesting user information

.js-Code:

function getUserLogin() 
{
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() 
    {
        if (this.readyState == 4 && this.status == 200) 
        {
            jsonUserobject = JSON.parse(this.responseText);
        }
    };
    console.log("FULL URL: https://api.twitch.tv/kraken/user?client_id=MYCLIENTID&oauth_token="+getUserID());
    xhttp.open("GET", "https://api.twitch.tv/kraken/user?client_id=MYCLIENTID&oauth_token="+getUserID(), true);
    xhttp.send();
}

.js-Code including .php curl:
AJAX:

  function getUserLogin() 
{
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() 
    {
        if (this.readyState == 4 && this.status == 200) 
        {
            jsonUserobject = JSON.parse(this.responseText);
        }
    };
    xhttp.open("GET", "scripts/php/getUserInfo.php?userid="+getUserID(), true);
    xhttp.send();
  }

PHP:

<?php
    $user = $_GET['userid'];
    
    $url = 'https://api.twitch.tv/kraken/user?client_id=MYCLIENTID&oauth_token='.$user;
    
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 3);
    
    $result = curl_exec($ch);
    curl_close($ch);

    echo $result;
?>

Also tried the curl-thing with $headers as an option added to $ch, but didn´t help!

Thanks in advance for every Solution and Advice! :slight_smile:

Edit: Dunno why my entry tries to put the whole PHP in one line … doesnt look like that while im writing it in the editor , sorry for that!