> This page is for Browser SDK, version v3.
> For other versions, use one of these documentation indexes:
> - v4 (default): https://signalwire.com/docs/browser-sdk/v4/llms.txt
> - v3: https://signalwire.com/docs/browser-sdk/v3/llms.txt
> - v2: https://signalwire.com/docs/browser-sdk/v2/llms.txt

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# updateToken

> updateToken method for the SignalWire Client.

### 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`** `string` — required

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

```javascript
import { SignalWire } from "@signalwire/js";

async function main() {
  const client = await SignalWire({
    token: "<TOKEN>",
    onRefreshToken: () => {
      let newToken = refreshToken(); // this function should refresh token as per OAuth2 protocol
      client.updateToken(newToken);
    },
  });
}
```