After reloading my React app lost auth and i need to manually press login button.
- I explored that this is due to 3rd party cookies being blocked (cookies were reset) and solved this with specifying autProvider to use localStorage:
<Auth0Provider
cacheLocation="localstorage"
However i also found out that custom domains may solve this problem. And i added custom domain. Now i have cookies beeing preserved in browser, but if i change cache location to memory there is still no autologin, despite cookies are exist.
How to solve this? Should i invoke special methods in auth sdk? Have auth0 cookies in browser but still need to manually press login button to actually login
I have tried addig this to my app.tsx. But i honestly do not understand, why do i need accessToken when working with SPA, but anyway:
const { getAccessTokenSilently } = useAuth0();
getAccessTokenSilently().catch((e) => console.error(e));
this returns error:
Error: Missing Refresh Token (audience: '', scope: 'openid profile email offline_access')
Token rotation and other token related stuff enabled in dashboard app settings and in authProvider:
<Auth0Provider
cacheLocation="memory"
domain={import.meta.env.VITE_AUTH0_DOMAIN as string} // my custom domain here
useRefreshTokens={true}
clientId={import.meta.env.VITE_AUTH0_ID as string}
authorizationParams={{
redirect_uri: window.location.origin,
}}
>
I also tried to add my standard auth api url to audience:
getAccessTokenSilently({
authorizationParams: {
audience: "https://dev-68o3zkhek7iateoYY0i.us.auth0.com/api/v2/",
},
}).catch((e) => console.error(e));
Same error but with specified audience.
Tried
audience: `https://MY_CUSTOM_DOMAIN/api/v2/`,
without any results with same error