I have a React Remix application, and I am trying to handle refreshing access tokens when they have expired. I have activated offline_access and the OAuth2 strategy should be configured correctly.
First i tried to use the strategy.refreshToken(refreshToken)
function from this documentation, as we use the OAuth2Strategy with Auth0 as the provider (this is taken from the remix auth with OAuth2Strategy documentation). However, this didnt work and I kept getting “UnexpectedResponseError: Unexpected error response” with a vite server response of 500 , but i couldnt figure out why. Then i tried to use the Auth0 documentation for manually refreshing a token with this code:
curl --request POST \
--url '``https://{domain}/oauth/token``' \
--header 'content-type: application/x-www-form-urlencoded' \
--data grant_type=refresh_token \
--data 'client_id={clientID}' \
--data 'client_secret={yourClientSecret}' \
--data 'refresh_token={yourRefreshToken}'
But when i did this i kept getting: {“error”:“access_denied”,“error_description”:“Invalid URL”}%
(I have triple checked that the variables are correct).
What could be wrong with the way I am trying to refresh an access token? I couldnt find any good documentation on the error messages so I am a bit lost.