# Getting a refresh token after API returns 401

**URL:** <https://community.auth0.com/t/getting-a-refresh-token-after-api-returns-401/45414>\
**Category:** Get Help\
**Created:** [June 28, 2020, 5:07pm UTC](https://community.auth0.com/t/getting-a-refresh-token-after-api-returns-401/45414 "2020-06-28T17:07:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsherman10](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jsherman10/32/12929_2.png) [@jsherman10](https://community.auth0.com/u/jsherman10)\
**Post date:** [June 28, 2020, 5:07pm UTC](https://community.auth0.com/t/getting-a-refresh-token-after-api-returns-401/45414/1 "2020-06-28T17:07:40Z")

</div>

Hi  
quick question, I’m trying to integrate auth0 into my SPA (react/redux) with embedded login and I’ve been reading the documentation. It regards to access token expiration, it states:

Read the `expires_in` response parameter returned by Auth0.  
Ignore expiration dates altogether. Instead, renew the Access Token if your API rejects a request from the application (such as with a 401).

If I do the latter, can I not use getSession() then? Also, if I wanted to use the expires\_in, do I just make a check every time I call an API to see if it’s almost expired?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 29, 2020, 8:53pm UTC](https://community.auth0.com/t/getting-a-refresh-token-after-api-returns-401/45414/3 "2020-06-29T20:53:11Z")

</div>

Hi @jsherman10,

I think you are talking about checkSession(). You can use check session to get a new token. The flow would go like this: send token to your custom API, the API returns a 401 expired token error, then you use checksession to silently renew the access token and make another call to the API.

P.S. a refresh token is a whole different type of token. You are talking about renewing an access token.

---

<div class="post-metadata">

**Author:** ![jsherman10](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jsherman10/32/12929_2.png) [@jsherman10](https://community.auth0.com/u/jsherman10)\
**Post date:** [June 30, 2020, 2:21am UTC](https://community.auth0.com/t/getting-a-refresh-token-after-api-returns-401/45414/4 "2020-06-30T02:21:56Z")

</div>

@dan.woda

Thank you so much for your reply, I just a follow up question:

If I plan on using embedded login, I have no choice but to use auth0.js which doesn’t currently support PCKE? so I would also be forced to use implicit grant flow?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 1, 2020, 8:14pm UTC](https://community.auth0.com/t/getting-a-refresh-token-after-api-returns-401/45414/5 "2020-07-01T20:14:09Z")

</div>

Hi @jsherman10,

That is correct. We highly recommend using Universal login, but if you must use embedded that would be the way to go.

---

<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:** [July 16, 2020, 8:14pm UTC](https://community.auth0.com/t/getting-a-refresh-token-after-api-returns-401/45414/6 "2020-07-16T20:14:09Z")

</div>

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