# RefreshToken is missing in token response

**URL:** <https://community.auth0.com/t/refreshtoken-is-missing-in-token-response/102014>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-react\
**Created:** [March 7, 2023, 8:27pm UTC](https://community.auth0.com/t/refreshtoken-is-missing-in-token-response/102014 "2023-03-07T20:27:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpvlaxmi](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@tpvlaxmi](https://community.auth0.com/u/tpvlaxmi)\
**Post date:** [March 7, 2023, 8:27pm UTC](https://community.auth0.com/t/refreshtoken-is-missing-in-token-response/102014/1 "2023-03-07T20:27:41Z")

</div>

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)](https://github.com/auth0-developer-hub/spa_react_javascript_hello-world/tree/basic-authentication) 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](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](http://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](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

---

<div class="post-metadata">

**Author:** ![tpvlaxmi](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@tpvlaxmi](https://community.auth0.com/u/tpvlaxmi)\
**Post date:** [March 9, 2023, 4:21pm UTC](https://community.auth0.com/t/refreshtoken-is-missing-in-token-response/102014/3 "2023-03-09T16:21:29Z")

</div>

I could be able to resolve getting refresh token issue by enabling “Refresh Token Rotation” and “Refresh Token Rotation” properties under Auth0 application settings in Auth0 page.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/c/4/c4c3f3648a76eedd330006f9381098fc7ba4a110.png)

Now I am having different problem that refeshToken is not storing in local Storage. .  
Following properties are mentioned in authorize call.

```auto
useRefreshTokens: true,
cacheLocation: ‘localstorage’,

```

I have used following code block to get local storage and also used developer tools to see local storage. Both the cases length of the local storage is 0.

```auto
      const refresh_token = new LocalStorageCache;
      const key = refresh_token.allKeys().find(key => key.includes(AUTH0_KEY_PREFIX));
      const refresh_token_value = refresh_token.get(key);
      Helper.addToRespField("Got refresh Token" + refresh_token_value);

```

I would appreciate your help on above problem.

Thanks  
Laxmi

---

<div class="post-metadata">

**Author:** ![tpvlaxmi](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@tpvlaxmi](https://community.auth0.com/u/tpvlaxmi)\
**Post date:** [March 13, 2023, 8:14pm UTC](https://community.auth0.com/t/refreshtoken-is-missing-in-token-response/102014/4 "2023-03-13T20:14:08Z")

</div>

I was setting cacheLocation as authorizationParams instead at Auth0Provider level. After moving that value to it Auth0Provider, I can see local storage is getting populated with the information.

```auto
const authorizationParams = {
    scope: scope,
    redirect_uri: redirectUri,
    audience: audience,
    connection: connectionId
  };

  return (
    <Auth0Provider
      domain={domain}
      clientId={clientId}
      cacheLocation="localstorage"
      cache={customStorageCache}
      useRefreshTokens={true}
      onRedirectCallback={onRedirectCallback}
      authorizationParams={authorizationParams} >
      {children}
    </Auth0Provider>
  );

```

On refresh it was navigating to login screen even refreshToken is enabled. I have to add isLoading check to app.tsx file and auto login only when isAuthenticated is not true. It took care of redirecting to “loginWithRedirect → returnTo” page.  
It will be helpful, if someone is having issues.

```auto
const { isLoading } = useAuth0();
    return (
        <>
            {isLoading && (
                <div className="page-layout">
                    <PageLoader />
                </div>
            )}
            {!isLoading && (
                <Routes>
                    <Route
                        path="/"
                        element={<Home />} />
                    <Route
                        path="/home"
                        element={<Home />} />
                    <Route
                        path="/callback"
                        element={<CallbackPage />} />
                    <Route
                        path="/protected"
                        element={<AuthenticationGuard component={MyProtectedPage} />}
                    />
                    <Route
                        path="*"
                        element={<NotFoundPage />} />
                </Routes>
            )}
        </>
    );

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [March 13, 2023, 8:39pm UTC](https://community.auth0.com/t/refreshtoken-is-missing-in-token-response/102014/5 "2023-03-13T20:39:17Z")

</div>

Hey there @tpvlaxmi thanks for following up with the community on the resolution, much appreciated!

Linking documentation to `authorizationParams` for future reference - Hopefully this helps others in realizing that `cacheLocation` is _not_ a property of `authorizationParams` but `Auth0Provider` like you mentioned:

> **[AuthorizationParams | @auth0/auth0-spa-js](https://auth0.github.io/auth0-spa-js/interfaces/AuthorizationParams.html)**
>
> Documentation for @auth0/auth0-spa-js

Cheers!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 27, 2023, 8:39pm UTC](https://community.auth0.com/t/refreshtoken-is-missing-in-token-response/102014/6 "2023-03-27T20:39:22Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
