
- Twitch login how to#
- Twitch login code#
- Twitch login password#
Third-party apps that call the Twitch APIs and maintain an OAuth session must call the /validate endpoint to verify that the access token is still valid. When this happens, you’ll need to get a new access token using the appropriate flow for your app.
Twitch login code#
If a token becomes invalid, your API requests return HTTP status code 401 Unauthorized.
The user disconnects your app by going to their account’s /settings/connections page and clicking Disconnect next to your app’s name. Tokens don’t last foreverĪccess and refresh tokens can become invalid for the following reasons: Passing the access token to the APIĪfter getting an access token using one of the above authentication flows, use it to set an API request’s Authorization header.įor an API request that shows using the header, see Get channel information. You cannot use the ID token in place of a user or app access token when calling the Twitch API. It’s used in OpenID Connect client apps to sign in users. NOTE An ID token or identity token encodes the user’s identity in a JSON Web Token (JWT). The following table summarizes the flows you can use and the type of access token it returns. For details, see Getting an app access token using the client credentials grant flow. To get an app access token, use the client credentials grant flow. If you call the EventSub APIs, you must also get an app access token because the calls fail if you try to use a user access token. The exception is if you call the EventSub APIs (for example, Create EventSub Subscription). But if your app also calls APIs that require a user access token, you should just get a user access token because in most cases you can use the user access token to call APIs that accept app access tokens. You should get an app access token, if your app only calls APIs that don’t require the user’s permission to access the resource. For example, you can get a list of videos without the user’s permission. For details about getting a user access token using this flow, see Getting a user access token using the authorization code grant flow.ĪPIs that don’t require the user’s permission to access resources use app access tokens. Use this flow if your app uses a server, can securely store a client secret, and can make server-to-server requests to the Twitch API. For details about getting a user access token using this flow, see Getting a user access token using the implicit grant flow. For example, use this flow if your app is a client-side JavaScript app or mobile app. Use this flow if your app does not use a server. If the user clicks Authorize, Twitch gives your app an access token that lets it perform those actions.īased on the type of app you’re building, you’ll use one of the following OAuth flows to get a user access token. The following example shows the dialog that Twitch displays to the user to get their permission for your app to create a Poll, stop a Poll, or get a list of their Polls.
For example, you don’t need permission to get a user’s User resource but you do need their permission to include their email address with the resource.
Twitch uses scopes to identify the resources, or the fields within a resource, that your app needs permission to access. User access tokensĪPIs that require the user’s permission to access resources use user access tokens.
Twitch login password#
IMPORTANT Treat access tokens, refresh tokens, and client secrets like a password and safeguard them. Some APIs require a user access token, others require a user access token or an app access token, and a few like the EventSub APIs require app access tokens. The reference content for each API identifies the type of access token you must use to access its resource. The Twitch APIs use two types of access tokens: user access tokens and app access tokens.
Twitch login how to#
If you’re not already familiar with the specification, reading it may help you better understand how to get access tokens to use with the Twitch API. Twitch APIs use OAuth 2.0 access tokens to access resources.