Skip to main content
Replaces the current JWT authentication token with a new one for continued secure communication. This is commonly used when tokens expire or are refreshed during a session.

Syntax

instance.updateAuthToken(token);

Parameters

token
string
required
The new JWT token to be set in the chat configuration.

Returns

void
Returns a void operator.

Examples

The following examples show different ways to update the authentication token:
// Update token when it expires
instance.on('authTokenNeeded', async (event, instance) => {
    const newToken = await fetchNewAuthToken();
    instance.updateAuthToken(newToken);
});

// Proactively refresh token
const refreshToken = async () => {
    const newToken = await getRefreshedToken();
    instance.updateAuthToken(newToken);
};

Do you need practical examples?

Learn how to apply the features available for embedded chat into your implementation with guidance and examples.