# When a user's third-party consented access\_token expires

**URL:** <https://community.auth0.com/t/when-a-users-third-party-consented-access-token-expires/55656>\
**Category:** Get Help\
**Tags:** consent, jwt, api, auth0\
**Created:** [January 4, 2021, 11:32am UTC](https://community.auth0.com/t/when-a-users-third-party-consented-access-token-expires/55656 "2021-01-04T11:32:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![carolus](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/carolus/32/13315_2.png) [@carolus](https://community.auth0.com/u/carolus)\
**Post date:** [January 4, 2021, 11:32am UTC](https://community.auth0.com/t/when-a-users-third-party-consented-access-token-expires/55656/1 "2021-01-04T11:32:34Z")

</div>

I have this challenge and not sure how to correctly deal with it.

We have an application with API, we also have a third party application that needs to access the API on behalf of their users. These third party application must get their user’s consent to access the first-party.

What we are doing at the moment is to have the third-party application store the access\_token provided during consent with the user’s account. This enables the third-party app to then call the API on behalf of the user. This works fine but the challenge comes in when that access\_token expires and the thrid party still needs to call the API on the user’s behalf. This consent should be given to the third-party application indefinately. (The user still has the ability on the first-party app to revoke this grant at any time)

How do we deal with I when the access\_token expires as we do not want ask the user for their consent as they will not be online and it is not UX friendly?  
Can we set this granted access\_token to never expire or do we also have include offline\_access to use a refresh token?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 4, 2021, 12:49pm UTC](https://community.auth0.com/t/when-a-users-third-party-consented-access-token-expires/55656/3 "2021-01-04T12:49:24Z")

</div>

Hi @carolus,

> [@carolus](#):
>
> Can we set this granted access\_token to never expire or do we also have to include offline\_access to use a Refresh Token?

It is not possible to configure an Access Token to never expire (the limit is 30 days). This is in order to follow [OAuth 2.0 recommendations](https://tools.ietf.org/html/rfc6750#page-11) for securely handling bearer tokens:

> Issue short-lived bearer tokens: Token servers SHOULD issue  
> short-lived (one hour or less) bearer tokens, particularly when  
> issuing tokens to clients that run within a web browser or other  
> environments where information leakage may occur. Using  
> short-lived bearer tokens can reduce the impact of them being  
> leaked.

Because Access Tokens are bearer tokens used to access an API on a user’s behalf, they must have an expiration in order to handle the threat of token capture and replay attacks.

This means that it’d be best to include `offline_access` and use a Refresh Token. The docs on [Refresh Tokens](https://auth0.com/docs/tokens/refresh-tokens) explain how to do this, and there are examples for using Auth0 SKDs in the [QuickStarts](https://auth0.com/docs/quickstart/webapp).

---

<div class="post-metadata">

**Author:** ![carolus](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/carolus/32/13315_2.png) [@carolus](https://community.auth0.com/u/carolus)\
**Post date:** [January 6, 2021, 6:14pm UTC](https://community.auth0.com/t/when-a-users-third-party-consented-access-token-expires/55656/4 "2021-01-06T18:14:19Z")

</div>

Thanks! …implemented.

---

<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:** [January 21, 2021, 6:14pm UTC](https://community.auth0.com/t/when-a-users-third-party-consented-access-token-expires/55656/5 "2021-01-21T18:14:24Z")

</div>

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