Auth0 refresh_token exchange fails (“Invalid URL” / UnexpectedResponseError) with Remix Auth OAuth2Strategy

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.

Hi @anna.jacobsen

Welcome to the Auth0 Community!

Reading through your use-case, one of the main causes for this behaviour would be if your application has been configured to use a Custom Domain, but the curl command you are trying to use points to your Auth0 tenant instead. I recommend checking in your Auth0 tenant under Tenant Settings > Custom Domains and change the token endpoint accordingly.

Let me know if this was the cause of the issue!

Best regards,
Gerald