I can't get the authentication token for the API

Hello, I’m programming a bot on discord in node.js that sends notifications whenever streamers are live, but I’m not getting the authentication token to use the API, I don’t know the correct method to do this and I need help.

What did you try?

For this sort of use case usually an App Access/Client Credentials token applies

I’m using Postman to get the token, but I get error 400 and I don’t know how to fix it, I’m new to APIs

https://id.twitch.tv/oauth2/token?client_id=xxxx&client_secret=xxxx&grant_type=authorization_code&redirect_uri=http://localhost

{

    "status": 400,

    "message": "missing code"

}

The request you’re making is Step 3 of the Auth Code flow, it wont work if you don’t do the steps before it.

If you don’t need any permissions from a user you should use the Client Credentials flow for an App token like that which Barry linked.

I got the access token, but what do I do with it, do I need to validate it?

My Code:

headers:
{ 
					"Client-ID": 'twitchClientID' ,
  "Authorization": 'Bearer tokentwitch' 
    } };

Error:

{"error":"Unauthorized","status":401,"message":"Invalid OAuth token"}

I discovered the reason for the error, it was a simple error in the code

the headers were wrong:

headers:
    { 
                "Client-ID": 'twitchClientID' ,
      "Authorization": 'Bearer tokentwitch' 
        } };

right headers:

headers:
    { 
                "Client-ID": twitchClientID,
      "Authorization": 'Bearer ' + tokentwitch
        } };

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