Skip to content

Authentication using an identity provider

Use this when your users already sign in — with Auth0, Amazon Cognito, Firebase, Okta, Google, or any OIDC provider. You don’t build a separate login for chat. Register your provider’s public keys with TalkLabs once, and from then on the token your users already carry is enough to join a room.

You don’t run an auth backend, store users, or write any token-minting code — TalkLabs validates the token your provider issued and starts the chat session.

What it takes: one configuration call (Step 1), then hand the token your provider already issues to the SDK (Step 2). That’s the whole integration.

sequenceDiagram
    actor U as User
    participant App as Your App
    participant IdP as Identity Provider
    participant ST as TalkLabs
    participant Keys as Provider public keys

    U->>App: Open app
    App->>IdP: Authenticate (existing login)
    IdP-->>App: Signed token
    App->>ST: Join room · Authorization: Bearer <token>
    ST->>Keys: Fetch public keys (cached)
    Keys-->>ST: Public keys
    ST->>ST: Verify signature, issuer & audience
    ST-->>App: Chat session + room subscription
    App->>ST: Listen for events
    ST-->>App: Messages, reactions, moderation events

Step 1 · Configure your provider (one time)

Section titled “Step 1 · Configure your provider (one time)”

Before any user token will be accepted, tell TalkLabs how to validate tokens from your provider. Today this is a one-time setup call you run per application with your management key (not your public app key), or set in the Dashboard.

Configure your identity provider (run once)
curl -X PUT \
"https://api.sportstalk247.com/api/v3/manage/applications/application/$APP_ID/identityprovider" \
-H "Authorization: Bearer $MANAGEMENT_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "external_jwks",
"issuer": "https://your-tenant.us.auth0.com/",
"audience": "https://chat.your-app.com",
"jwksuri": "https://your-tenant.us.auth0.com/.well-known/jwks.json",
"claimmappings": {
"userid": "sub",
"name": "name",
"img": "picture"
}
}'
FieldWhat it is
typeMust be external_jwks for this flow (required).
issuerThe iss your provider stamps on every token. Must match exactly.
audienceThe aud your tokens are issued for (your chat API identifier).
jwksuriWhere TalkLabs fetches your provider’s public keys. Cached and refreshed automatically.
claimmappingsWhich token claims become the user’s id (userid), display name (name), and avatar (img).

You do this once (or when you rotate providers). After that, every user token from that issuer is accepted at runtime.

Get the token your provider already issues, hand it to the SDK, and join a room. No secret in the browser.

app.js — sportstalk-sdk
import { ChatClient } from 'sportstalk-sdk';
// Public app id only — no secret in the browser.
const client = ChatClient.init({ appId: APP_ID });
// The token your identity provider already issued for this user.
const jwt = await auth.getAccessToken();
// Hand it to TalkLabs. It's validated against the keys you configured in Step 1.
client.setUserToken(jwt);
// Your user — the same id your provider puts in the token (its 'sub'); we check they match.
client.setUser({ userid: 'u-8842' });
// Join a room — you're in as the user the token identifies.
await client.joinRoomByCustomId('live-event-chat');