Skip to content

Authentication using my identities

Use this when you already manage your own users and want them in chat as themselves. Your server makes one call to mint a token for a signed-in user; your app hands that token to the SDK, and from then on every widget and component acts as exactly the identity you minted.

What it takes: one server-side mint call, then a setUserToken on the client. Your backend stays the source of truth — no passwords or user records to sync.

Call the mint endpoint with the user’s id. The response’s data.token is a ready-to-use bearer token for that user.

POST /api/v3/{appid}/user/users/{userid}/session — your API key in the x-api-token header. Body is optional (send {} for defaults; expiresIn sets a lifetime in seconds).

mint.mjs — runs on your server
const res = await fetch(
`https://api.sportstalk247.com/api/v3/${APP_ID}/user/users/u-8842/session`,
{
method: 'POST',
headers: {
'x-api-token': API_KEY, // secret — server only
'Content-Type': 'application/json',
},
body: JSON.stringify({ displayname: 'Dave', expiresin: 3600 }),
},
);
const { data } = await res.json();
return data.token; // hand this to the browser

Send the minted token to the browser, hand it to the SDK, and join a room. The token is the user’s identity — no secret in the browser.

app.js — sportstalk-sdk
import { ChatClient } from 'sportstalk-sdk';
// Public app id only. The minted token identifies the user.
const client = ChatClient.init({ appId: APP_ID });
// The token your server minted in Step 1.
client.setUserToken(mintedToken);
// Tell the SDK who's joining — must match the userid the token was minted for,
// or the server rejects the join (an end-user token can only act as itself).
client.setUser({ userid: 'u-8842' });
// Join a room — you're in as that user.
await client.joinRoomByCustomId('live-event-chat');