I have Static React web application. I am deploying the app into Node Express server. Accessing the application using localhost.
I am using auth0-react 2.0.0 react component and sample code has taken from following auth0-developer-hub/spa_react_javascript_hello-world at basic-authentication (github.com) github location.
My requirement to get accessToken using refreshToken when it expires. However, https://<my_domain.auth0.com>/oauth/token URL is returning everything except refreshToken.
So I could not get new accessToken when original is expired.
Offline access is enabled for Auth0 application. When we try to get refresh token from other programming language it works.
Auth0 Provider code:
const domain = âvalid_auth0_domainâ;
const clientId = âvalid_client_idâ;
const redirectUri = âhttp://localhost:8080/callbackâ;
const connectionId = âvalid connectionidâ;
const scope = âopenid offline_accessâ;
const audience = âvalid audienceâ;
const promptType = âloginâ;
return (
<Auth0Provider
domain={domain}
clientId={clientId}
authorizationParams={{
useRefreshTokens: true,
cacheLocation: âlocalstorageâ,
scope: âopenid offline_accessâ,
redirect_uri: redirectUri,
audience: audience,
connection: connectionId
}}
onRedirectCallback={onRedirectCallback}
>
{children}
);
Authorization Call request:
https://.auth0.com/authorize?client_id=<client_id>&scope=openid+offline_access&domain=.auth0.com&useRefreshTokens=true&cacheLocation=localstorage&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fcallback&audience=https%3A%2F%2FXXX.co&connection=XYZ&prompt=login&response_type=code&response_mode=query&state=ZHBxYVBZMy1ja2hQRmVEekl1a1BJZ040S1lhR3lGV0t%2BbFNoeDBaZllmNw%3D%3D&nonce=SzNoSUtadVVDfmVCLXZydWlBZnREMFIwQTIzT3pDVkN3ZkpET3BFLmg5dw%3D%3D&code_challenge=G_gEA3lWJ46wzdFHTH2ppRUmYO0B5HCS-t54s7Y_oWU&code_challenge_method=S256&auth0Client=eyJuYWXYZXX
Note: I have tried both memory/localstorage as cacheLocation. In both cases refreshToken is not fetched at token call.
No parameters are fed to getAccessTokenSilently method.
const token = await getAccessTokenSilently();
Request Payload:
client_id=<client_id>&code_verifier=_GAb6EDotFpJyzB%7E%7EIhDmB4Z1HjuAN-3ydF1Zqj2_bK&grant_type=authorization_code&code=XXXXX&redirect_uri=http://localhost:8080/callback
Authorization Token Call Response:
access_token: â<acces_token>â
expires_in: 1800
id_token: â<id_token>â
scope: âopenid offline_accessâ
token_type: âBearerâ
I would appreciate your response.
Thanks
Laxmi
