updateToken

View as Markdown

updateToken

  • updateToken(token: string): Promise<void>

Update the auth token being used by the client. Use this when the old token is about to expire and you have refreshed it through OAuth2.

Parameters

token
stringRequired

The new token that the client should start to use.

Returns

Promise<void>

Returns empty object when successful. Throws an error with the server’s error message when unsuccessful.

Example

1import { SignalWire } from "@signalwire/js";
2
3async function main() {
4 const client = await SignalWire({
5 token: "<TOKEN>",
6 onRefreshToken: () => {
7 let newToken = refreshToken(); // this function should refresh token as per OAuth2 protocol
8 client.updateToken(newToken);
9 },
10 });
11}