# Error: Missing Refresh Token (SPA SDK)

**URL:** <https://community.auth0.com/t/error-missing-refresh-token-spa-sdk/184942>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [April 2, 2025, 11:43pm UTC](https://community.auth0.com/t/error-missing-refresh-token-spa-sdk/184942 "2025-04-02T23:43:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyeotic](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kyeotic/32/73734_2.png) [@kyeotic](https://community.auth0.com/u/kyeotic)\
**Post date:** [April 2, 2025, 11:43pm UTC](https://community.auth0.com/t/error-missing-refresh-token-spa-sdk/184942/1 "2025-04-02T23:43:49Z")

</div>

I’m trying to enable refresh tokens using the SPA SDK, but running into errors.

I have enabled tokens in the app settings.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/a/2/a2be1a454b2a783efb213c3252f630b5d023b888.png)

I have setup the Auth0Client

```javascript
new Auth0Client({
  domain: config.auth0.domain,
  clientId: config.auth0.clientId,
  cacheLocation: 'localstorage', // tried with and without this
  useRefreshTokens: true,
  authorizationParams: {
    redirect_uri: `${window.location.protocol}//${window.location.host}`,
    scope: config.auth0.scope, // tried with and without this
  },
})

```

I have tried with and without “scope” on the client.authorizationParams, as well as with and without “scope” on the getTokenSilently() and loginWithRedirect() calls.

It always results in an error after redirecting back from the Universal login page

`Error: Missing Refresh Token (audience: 'MY_AUDIENCE', scope: 'openid profile email offline_access')`

---

<div class="post-metadata">

**Author:** ![kyeotic](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kyeotic/32/73734_2.png) [@kyeotic](https://community.auth0.com/u/kyeotic)\
**Post date:** [April 3, 2025, 12:16am UTC](https://community.auth0.com/t/error-missing-refresh-token-spa-sdk/184942/2 "2025-04-03T00:16:43Z")

</div>

I figured it out, I was handling login incorrectly.

I had been calling `loginWithRedirect()` and to login and `getTokenSilently()` on page load to get the token. This was actually working all by itself, until I added refresh token. Perhaps it shouldn’t have been?

I needed to be calling `handleRedirectCallback()` to handle login, before calling `getTokenSilently()`. After adding this, everything is working.

I sure wish `handleRedirectCallback()` did the work of stripping the auth parameters out of the querystring so that hitting refresh didnt cause a failure.

---

<div class="post-metadata">

**Author:** ![jackiegleason](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jackiegleason/32/8119_2.png) [@jackiegleason](https://community.auth0.com/u/jackiegleason)\
**Post date:** [April 5, 2025, 3:27am UTC](https://community.auth0.com/t/error-missing-refresh-token-spa-sdk/184942/3 "2025-04-05T03:27:01Z")

</div>

Can you give an example because I am still having trouble getting it to work

---

<div class="post-metadata">

**Author:** ![kyeotic](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kyeotic/32/73734_2.png) [@kyeotic](https://community.auth0.com/u/kyeotic)\
**Post date:** [April 5, 2025, 3:59am UTC](https://community.auth0.com/t/error-missing-refresh-token-spa-sdk/184942/4 "2025-04-05T03:59:08Z")

</div>

Sure thing, [this is the repo](https://github.com/kyeotic/smashdown/blob/main/src/client/auth/AuthProvider.tsx) I am using it in. Feel free to poke around.

If you share your error or config I might be able to point you in the right direction.

---

<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:** [April 19, 2025, 3:59am UTC](https://community.auth0.com/t/error-missing-refresh-token-spa-sdk/184942/5 "2025-04-19T03:59:34Z")

</div>

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