Skip to Content

Twitch

At this time, Arcade does not offer a default Twitch . To use Twitch auth, you must create a custom Auth Provider with your own Twitch OAuth 2.0 credentials as described below.

The Twitch enables tools and to call the Twitch API on behalf of a .

What’s documented here

This page describes how to use and configure Twitch auth with Arcade.

This is used by:

Configuring Twitch auth

When using your own app credentials, make sure you configure your to use a custom user verifier. Without this, your end-users will not be able to use your app or in production.

In a production environment, you will most likely want to use your own Twitch app credentials. This way, your will see your application’s name requesting permission.

Before showing how to configure your Twitch app credentials, let’s go through the steps to create a Twitch app.

Create a Twitch app

  • Twitch requires that you have two-factor authentication enabled for your . Enable in your account security seetings 
  • Create a Twitch Application in the Twitch App Console 
  • Set the OAuth Redirect URL to the redirect URL generated by Arcade (see below)
  • Select your Application category
  • Select the ‘Confidential’ Client Type
  • Copy the App key (Client ID) and App secret (Client Secret), which you’ll need below

Next, add the Twitch app to Arcade.

Configuring your own Twitch Auth Provider in Arcade

Configure Twitch Auth Using the Arcade Dashboard GUI

Access the Arcade Dashboard

To access the Arcade Cloud dashboard, go to api.arcade.dev/dashboard . If you are self-hosting, by default the dashboard will be available at http://localhost:9099/dashboard . Adjust the host and port number to match your environment.

  • Under the OAuth section of the Arcade Dashboard left-side menu, click Providers.
  • Click Add OAuth Provider in the top right corner.
  • Select the Included Providers tab at the top.
  • In the Provider dropdown, select Twitch.

Enter the provider details

  • Choose a unique ID for your provider (e.g. “my-twitch-provider”).
  • Optionally enter a Description.
  • Enter the Client ID and Client Secret from your Twitch app.
  • Note the Redirect URL generated by Arcade. This must be set as your Twitch app’s OAuth Redirect URL.

Create the provider

Hit the Create button and the provider will be ready to be used.

When you use tools that require Twitch auth using your Arcade credentials, Arcade will automatically use this Twitch OAuth provider. If you have multiple Twitch providers, see using multiple auth providers of the same type for more information.

Using Twitch auth in app code

Use the Twitch in your own and AI apps to get a -scoped token for the Twitch API. See authorizing agents with Arcade to understand how this works.

Use client.auth.start() to get a token for the Twitch API:

Python
from arcadepy import Arcade client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable user_id = "{arcade_user_id}" # Start the authorization process auth_response = client.auth.start( user_id=user_id, provider="twitch", scopes=["channel:manage:polls"], ) if auth_response.status != "completed": print("Please complete the authorization challenge in your browser:") print(auth_response.url) # Wait for the authorization to complete auth_response = client.auth.wait_for_completion(auth_response) token = auth_response.context.token # Do something interesting with the token...

Using Twitch auth in custom tools

You can author your own custom tools that interact with the Twitch API.

Use the Twitch() auth class to specify that a requires authorization with Twitch. The context.authorization.token field will be automatically populated with the ’s Twitch token:

Python
from typing import Annotated, Optional import httpx from arcade_tdk import ToolContext, tool from arcade_tdk.auth import Twitch @tool( requires_auth=Twitch( scopes=["channel:manage:polls"], ) ) async def create_poll( context: ToolContext, broadcaster_id: Annotated[ str, "The ID of the broadcaster to create the poll for.", ], title: Annotated[ str, "The title of the poll.", ], choices: Annotated[ list[str], "The choices of the poll.", ], duration: Annotated[ int, "The duration of the poll in seconds.", ], ) -> Annotated[dict, "The poll that was created"]: """Create a poll for a Twitch channel.""" url = "https://api.twitch.tv/helix/polls" headers = { "Authorization": f"Bearer {context.authorization.token}", "Client-Id": "your_client_id", "Content-Type": "application/json", } payload = { "broadcaster_id": broadcaster_id, "title": title, "choices": [{"title": choice} for choice in choices], "duration": duration, } async with httpx.AsyncClient() as client: response = await client.post(url, headers=headers, json=payload) response.raise_for_status() return response.json()
Last updated on