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
The new JWT token to be set in the chat configuration.
Returns
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.