Help me for code

function getUser(username) {
return fetch(`https://api.twitch.tv/helix/users?login=${username}`, {
    method: "GET",
    headers: {
        'Client-ID': "csj7l3h1nqr7iyd1vudl79q21dcen9",
        "Authorization": "OAuth pyfhpx64tz6z4fvpb1xf6lrix6gpi9",
        'Accept': 'application/vnd.twitchtv.v5+json'
    }
}).then(async (res) => res.json())
};

Result

{ error: 'Not Found', status: 404, message: 'This API does not exist' }
{
  error: 'Unauthorized',
  status: 401,
  message: 'The "Authorization" token is invalid.'
}

But my token true :frowning: help me pls

Dont need this header

Don’t leak generated tokens

The prefix for helix is Bearer not oAuth so your headers should be:

return fetch(`https://api.twitch.tv/helix/users?login=${username}`, {
    method: "GET",
    headers: {
        'Client-ID': "csj7l3h1nqr7iyd1vudl79q21dcen9",
        "Authorization": "Bearer MyToken",
    }
})

Code example demonstrating this kind of call Twitch Implicit Auth Example

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.