Worker object representing the current user. If the worker is already initialized, it will return immediately.
ReadonlyrolesReadonlytokenThis method updates the token for the session and propagates it to all connected services.
After a successful update, the tokenUpdated event is emitted with both the new token and refresh token.
Use this method when you need to manually refresh the token, such as when your application receives a new token from your backend token server.
The new authentication token
OptionalrefreshToken: stringThe new refresh token (optional)
Listen to token update events:
import { createClient, ClientEvent } from "@twilio/flex-sdk";
const client = await createClient("SDK_TOKEN");
// Listen for token updates
client.on(ClientEvent.TokenUpdated, (token, refreshToken) => {
console.log("Token updated successfully");
// Optionally store the new token
});
// Update the token
client.updateToken("NEW_TOKEN", "NEW_REFRESH_TOKEN");
Main interface for interacting with the Flex SDK.