Unable to handle errors when POST call to /oauth/token fails, when the call is made by @auth0/auth0-react SDK

Hi Team,

I am using @auth0/auth0-react SDK v2 in my React application, when I login and keep my keep a page in my application open for a long time and when refresh token expires (I have reduced refresh_token expiry time to 2 mins to simulate this issue in local), if I reload my page, I believe a POST call to /oauth/token endpoint is made by the SDK, since the refresh token has expired, the call fails with a 403 and I am unable to catch / handle this error. I am trying to avoid using the Iframe fallback method (useRefreshTokensFallback={true}).

Also when this fails, I was expecting that the error object exported by useAuth0 hook will contain some details about the failure, but its always set to undefined.

I am able handle the same error when I call getAccessTokenSilently explicitly from my code using a try catch block, the only challenge is when the call is made implicitly / by the SDK.

1 Like