onAuthorizationFailure()
function onAuthorizationFailure(callback: FailureCallback): void;
Registers a callback to handle authorization failures (401 errors). The callback should refresh the authentication token and return the new authorization header. The SDK will automatically retry the failed request with the new token.
Parameters
callback
FailureCallback
Async function that refreshes token and returns new authorization header
Returns
void
Example
onAuthorizationFailure(async (error) => {
const newToken = await refreshAuthToken();
sessionStorage.setItem('Authorization', newToken);
return newToken;
});