Skip to main content

Twitch

Sign in with Twitch accounts using OAuth 2.0.

1. Create OAuth App​

  1. Go to the Twitch Developer Console.
  2. Log in with your Twitch account.
  3. Click Register Your Application.
  4. Fill in:
    • Name: Your app name
    • OAuth Redirect URLs: Your EdgeBase callback URL (see below)
    • Category: Choose the most appropriate category
    • Client Type: Choose Confidential
  5. Click Create.

2. Set Redirect URI​

Set the OAuth Redirect URL during registration:

https://your-edgebase-url/api/auth/oauth/twitch/callback

For local development:

http://localhost:8787/api/auth/oauth/twitch/callback

3. Get Credentials​

After registration, click Manage on your app:

  • Client ID — Displayed on the app management page.
  • Client Secret — Click New Secret to generate one (copy it immediately).

4. Configure EdgeBase​

// edgebase.config.ts
export default defineConfig({
auth: {
allowedOAuthProviders: ['twitch'],
},
});
export default defineConfig({
auth: {
oauth: {
twitch: {
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
},
},
},
});

5. Usage​

client.auth.signInWithOAuth('twitch');

Provider Details​

PropertyValue
Scopesuser:read:email
PKCENo
EmailYes
Email verifiedYes — uses email_verified field
AvatarYes — profile_image_url
Refresh tokenYes

Notes​

  • Twitch may require Two-Factor Authentication (2FA) on the Twitch account before app registration or sensitive app actions are allowed in the current console.
  • Twitch's user info API requires a Client-Id header in addition to the Bearer token — EdgeBase handles this automatically.
  • The Twitch API returns users in an array format (data[0]), and EdgeBase extracts the first user.
  • Display name uses display_name if available, falling back to login (username).
  • Twitch provides verified emails, so automatic account linking with existing email accounts will work.
  • Local verification was completed on March 8, 2026 against http://localhost:8787/api/auth/oauth/twitch/callback using the js-web browser harness. The current result was 3 passed / 6 skipped, which is expected when the signed-in Twitch account does not unlock the password/email/TOTP checks in the harness.