authenticate

View as MarkdownOpen in Claude
1authenticate(): Promise<{ expiry_at: number; token: string; }>

Obtains the initial credentials. Called once during client initialization.

Implementor responsibilities:

  • Resolve with a valid SDKCredential on success.
  • Reject (throw) on failure — this will cause client initialization to fail.
  • When context.fingerprint is provided, forward it to the server-side token endpoint with scope: "sat:refresh" to enable automatic token refresh.

SDK behavior:

  • Awaits this method before establishing the WebSocket connection.
  • On rejection, propagates the error to the caller of SignalWire().

Returns

Promise<{ expiry_at: number; token: string; }>

Examples

1import { EmbedTokenCredentialProvider } from '@signalwire/js';
2
3const provider = new EmbedTokenCredentialProvider({
4 token: 'YOUR_EMBED_TOKEN',
5 host: 'your-space.signalwire.com',
6});
7
8// Called by the SDK during `new SignalWire(provider)` — typically not
9// invoked directly by application code.
10const credential = await provider.authenticate({ /* AuthenticateContext */ });