OAuth Integration

OAuth Overview

Allow users to authorize your application to access TikTok LIVE data on their behalf using the Euler Stream OAuth system.

The Euler Stream OAuth system enables third-party applications to securely access TikTok LIVE functionality on behalf of users. Instead of requiring users to share their TikTok session credentials directly, OAuth provides a secure, standardized authorization flow.

What is Euler Stream OAuth?

Euler Stream OAuth implements the industry-standard OAuth 2.0 Authorization Code flow with a TikTok-specific twist: users authenticate by scanning a QR code with their TikTok mobile app, ensuring secure credential handling without password exposure.

Key Benefits

  • User Control: Users explicitly approve what permissions your app receives
  • Security: TikTok credentials never touch your servers
  • Revocable: Users can revoke access at any time
  • Scoped Access: Request only the permissions your application needs

Quick Start

1. Create an OAuth Client

Navigate to Dashboard → OAuth and create a new OAuth client. You'll receive:

  • Client ID: Public identifier for your application
  • Client Secret: Keep this secret! Used for token exchange

2. Redirect Users to Authorize

Send users to the authorization endpoint:

https://www.eulerstream.com/tiktok/oauth/authorize?
  client_id=YOUR_CLIENT_ID
  &redirect_uri=https://yourapp.com/callback
  &response_type=code
  &scope=webcast:fetch webcast:bulk_live_check
  &state=RANDOM_CSRF_TOKEN

3. Handle the Callback

After authorization, users are redirected to your redirect_uri with an authorization code:

https://yourapp.com/callback?code=AUTHORIZATION_CODE&state=RANDOM_CSRF_TOKEN

4. Exchange Code for Tokens

Exchange the authorization code for access and refresh tokens:

const response = await fetch('https://tiktok.eulerstream.com/tiktok/oauth/token', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    grant_type: 'authorization_code',
    code: authorizationCode,
    redirect_uri: 'https://yourapp.com/callback',
    client_id: 'YOUR_CLIENT_ID',
    client_secret: 'YOUR_CLIENT_SECRET',
  }),
});

const result = await response.json();
// {
//   code: 200,
//   message: "Tokens issued successfully",
//   data: {
//     access_token: "...",
//     refresh_token: "...",
//     token_type: "Bearer",
//     expires_in: 3600,
//     refresh_expires_in: 2592000,
//     scopes: ["webcast:fetch", "webcast:bulk_live_check"]
//   }
// }

5. Make API Requests

Use the access token to make authenticated requests:

const response = await fetch('https://tiktok.eulerstream.com/webcast/fetch', {
  method: 'POST',
  headers: {
    'x-oauth-token': accessToken,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    unique_id: 'streamer_username',
  }),
});

Token Expiration Summary

Token TypeLifetimeAction Required
Access Token1 hourRefresh using refresh token
Refresh Token30 daysUser must re-authorize

Important: Users must re-authenticate every 30 days when the refresh token expires. Plan your application to handle this gracefully.

Integration Endpoints

EndpointURLPurpose
Authorizationhttps://www.eulerstream.com/tiktok/oauth/authorizeStart OAuth flow
Tokenhttps://tiktok.eulerstream.com/tiktok/oauth/tokenExchange codes/refresh tokens
Revokehttps://tiktok.eulerstream.com/tiktok/oauth/revokeRevoke tokens
Introspecthttps://tiktok.eulerstream.com/tiktok/oauth/introspectCheck token validity

Next Steps