Get 400 when try to get user info

Hi, i try to get user info with this code :

let fetchLink =  "https://api.twitch.tv/kraken/user"
      
      fetch(fetchLink, {
        mode: 'no-cors',
        method: 'get',
        headers: new Headers({
          'Client-ID': 'my client id',
          'Authorization': 'OAuth my token with user_read scope'
        })
      }).then(function (response){
        console.log(response);
        return response.json();
      }).then(data => {
        console.log(data);
      })
    }

And i got :

{“error”:“Bad Request”,“status”:400,“message”:“No client id specified”}

I don’t know why because i specify the cliend id

Thx for help

That suggests that

headers: new Headers({

doesn’t generate fetch compatible headers

Additionally kraken is deprecated

So all your need instead is

                // call API
                fetch(
                    'https://api.twitch.tv/helix/users',
                    {
                        "headers": {
                            "Client-ID": client_id,
                            "Authorization": "Bearer " + access_token
                        }
                    }
                )
                .then(resp => resp.json())
                .then(resp => {
//snip

See also Reference | Twitch Developers

1 Like

Thx a lot it works !

On Users Reference | Twitch Developers they say to use https://api.twitch.tv/kraken/user i don’t know why.

You have linked to the recently deprecated documentation

There is a banner at the top of the page detailing this. But you ulikely jumped in directly to that reference

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