Calling the getAccessTokenSilently API Returns the Same Access Token

Overview

Calling the getAccessTokenSilently API returns the same access token. This article describes how to ensure a new access token is issued.

Cause

By default, the auth0-spa.js library returns tokens from its’ cache instead of making requests to Auth0 if the tokens are still valid.

Solution

The cacheMod parameter can be set to off to overwrite this behavior to always retrieve new tokens from Auth0.

const token = await getAccessTokenSilently({cacheMode: “off”});