You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I tried to retrieve the user data, but unfortunately I always get a fatal error
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: GET https://api.twitch.tv/helix/users resulted in a 401 Unauthorized response: {"error": "Unauthorized", "status":401, "message": "Client ID and OAuth token do not match"}
Here is the code snippet I use:
`
$code = (isset($_GET['code']) and $_GET['code']) ? $_GET['code'] : null;
try {
$token = $oauth->getUserAccessToken($code, $login_query);
// It is a good practice to check the status code when they've responded, this really is optional though
if ($token->getStatusCode() == 200) {
// Below is the returned token data
$data = json_decode($token->getBody()->getContents());
// Your bearer token
$twitch_access_token = $data->access_token ?? null;
} else {
//TODO: Handle Error
}
} catch (Exception $e) {
//TODO: Handle Error
var_dump($e);
}
try {
// Make the API call. A ResponseInterface object is returned.
$response = $twitchlogin->getUsersApi()->getUserByAccessToken($twitch_access_token);
// Get and decode the actual content sent by Twitch.
$responseContent = json_decode($response->getBody()->getContents());
// Return the first (or only) user.
return $responseContent->data[0];
} catch (GuzzleException $e) {
//TODO: Handle Error
var_dump($e);
}`
The text was updated successfully, but these errors were encountered:
Be-Mann
changed the title
helix/users Unauthorized
Authorization Prolem when retrieving user data
Jul 21, 2023
Be-Mann
changed the title
Authorization Prolem when retrieving user data
Authorization problem when retrieving user data
Jul 21, 2023
In "RequestGenerator" $headers['client-id'] must be added to the header, then it works, but I didn't manage to retrieve the $clientId from OauthApi, I'm not so into object oriented programming.
Hi, I tried to retrieve the user data, but unfortunately I always get a fatal error
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error:
GET https://api.twitch.tv/helix/users
resulted in a401 Unauthorized
response: {"error": "Unauthorized", "status":401, "message": "Client ID and OAuth token do not match"}Here is the code snippet I use:
`
The text was updated successfully, but these errors were encountered: