...

>

Generate Access Tokens

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

client_id

String

Required

This is the registered client ID of an application created on the Twitch Developer Console

client_secret

String

Required

This is the registered client secret of an application created on the Twitch Developer Console.

grant_type

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 client_credentials.

If the POST request we make to this URL is successful, the server responds with a JSON object containing the ...