# getAccessTokenSilently doesn't call api when id\_token is expired

**URL:** <https://community.auth0.com/t/getaccesstokensilently-doesnt-call-api-when-id-token-is-expired/99301>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [January 30, 2023, 2:46pm UTC](https://community.auth0.com/t/getaccesstokensilently-doesnt-call-api-when-id-token-is-expired/99301 "2023-01-30T14:46:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dominikjasek](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dominikjasek/32/44083_2.png) [@dominikjasek](https://community.auth0.com/u/dominikjasek)\
**Post date:** [January 30, 2023, 2:46pm UTC](https://community.auth0.com/t/getaccesstokensilently-doesnt-call-api-when-id-token-is-expired/99301/1 "2023-01-30T14:46:06Z")

</div>

Hey, I downloaded spa react sample application. In Management of SPA application, I set expiration of ID Token to 5 seconds (only to demonstrate my problem).

 ![image](https://global.discourse-cdn.com/auth0/original/3X/9/3/93275c17d824e5d52f5606a65a639c2c225d4193.png)  
Whenever I call

`const tokens = await getAccessTokenSilently({detailedResponse: true})`,

I will get both `access_token` and `id_token`. Access token has expiration 86400 and id token 5s. After 5s, I call this function again, but values are taken from cache (apparantely because access\_token is not expired yet?). If I use

`const tokens = await getAccessTokenSilently({detailedResponse: true, cacheMode: "off"})`,

I get new valid id token, but that is not really what I would want to use in production application, as I want to use cache.

Btw I am using refresh tokens, but that shouldnt matter.

Thanks for any help.

---

<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:** [January 31, 2023, 3:05am UTC](https://community.auth0.com/t/getaccesstokensilently-doesnt-call-api-when-id-token-is-expired/99301/4 "2023-01-31T03:05:52Z")

</div>

Hey there @dominikjasek!

> [@dominikjasek](#):
>
> I will get both `access_token` and `id_token`. Access token has expiration 86400 and id token 5s. After 5s, I call this function again, but values are taken from cache (apparantely because access\_token is not expired yet?)

This is a bit tricky, but expected behavior - The call is not necessarily concerned with the ID token expiration. Essentially, because the ID token is only designed to be used on the client side it can more or less be discarded once the users information has been gathered from it. It just proves successful _authentication_ but not authorization (this is the access token). The ID token is irrelevant to the session established at the authorization server (in this case Auth0) which is checked when `getAccessTokenSilently` is called. So as you’ve noticed the ID token _may_ be renewed, but not necessarily.

> **[Session Layers](https://auth0.com/docs/manage-users/sessions/session-layers)**
>
> Describes layers created when users log in.

Hope this helps a bit!

---

<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:** [February 14, 2023, 3:06am UTC](https://community.auth0.com/t/getaccesstokensilently-doesnt-call-api-when-id-token-is-expired/99301/5 "2023-02-14T03:06:33Z")

</div>

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