You must complete steps 3 and 4 of the OAuth Authorization Code Flow to turn the code to an access_token: https://dev.twitch.tv/docs/authentication#oauth-authorization-code-flow-user-access-tokens
- On your server, get an access token by making this request:
POST https://api.twitch.tv/kraken/oauth2/token
?client_id=<your client ID>
&client_secret=<your client secret>
&code=<authorization code received above>
&grant_type=authorization_code
&redirect_uri=<your registered redirect URI>
Here is a sample request:
POST https://api.twitch.tv/kraken/oauth2/token
?client_id=uo6dggojyb8d6soh92zknwmi5ej1q2
&client_secret=nyo51xcdrerl8z9m56w9w6wg
&code=394a8bc98028f39660e53025de824134fb46313
&grant_type=authorization_code
&redirect_uri=http://localhost
- We respond with a JSON-encoded access token. The response looks like this:
{
"access_token": "<user access token>",
"refresh_token": "<refresh token>",
"expires_in": <number of seconds until the token expires>,
"scope": <your previously listed scope(s)>
}