Generate Access Tokens
Learn to generate app access and user access tokens for the Twitch API.
Generate an app access token
With our client ID and secret, we finally have everything we need to generate our access tokens. Let's start with the app access token.
We'll use the OAuth client credential grant flow to get our app access token. In this grant flow, the server directly authorizes an application, rather than a user, by generating an access token for the application once it provides its client ID and secret.
The illustration below gives an overview of this grant flow.
To retrieve our access token, we need to send an HTTP POST request to the following URL:
https://id.twitch.tv/oauth2/token
Here are the query parameters we pass to this call:
Parameter | Type | Category | Description |
| String | Required | This is the registered client ID of an application created on the Twitch Developer Console |
| String | Required | This is the registered client secret of an application created on the Twitch Developer Console. |
| String | Required | This is the type of grant flow we're using. Since we're using the client credential grant flow, the value of this parameter will be |
If the POST request we make to this URL is successful, the server responds with a JSON object containing the following properties:
Property | Type | Description |
| String | This is the app access token generated from the request. |
| Number | This is the time in seconds for which the generated token is valid. |
| String | This is the type of token generated from the request. Using the client credential grant flow, the type of token we get is |
Let's make an actual request to retrieve our access token. The code to make the call has already been provided, and it automatically ...