I’m trying to save my token in localstorage, using auth0 onRerirectCallback
const onRedirectCallback = async (appState) => {
try {
const token = await getAccessTokenSilently();
localStorage.setItem('token', token);
window.history.replaceState({}, document.title, appState?.returnTo || window.location.pathname);
} catch (error) {
console.error(error);
}
};
<Auth0Provider
domain={domain}
clientId={clientId}
redirectUri={window.location.origin}
onRedirectCallback={onRedirectCallback}
>
{children}
</Auth0Provider>
);
The functions is called, but I don’t get a token. What am I doing wrong ?