-1

I'm currently working on a project and I want a good way to send a POST request to refresh a token I'm using Axios interceptors to check before every request if the current access token is expired or not. if it is, I'm sending the POST request to refresh the token. My question is: how can I get this refresh token?

  const response = await axios.post(
    `/auth/refresh`,
    {
      refreshToken: (how can I get it?),
    }
  );
Markus
  • 5,976
  • 5
  • 6
  • 21
Aviv Alon
  • 21
  • 2

1 Answers1

0

To get the refresh token, the token provider must be configured to return it for that specific client.

Then you as a client, need to ask for the offline_access scope to get it back.

It all is configured, then you get the refresh token at the same time you get the ID and access tokens, likethis:

{
  "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IktLbkhNY3BfTkQ...",
  "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IktLbkhNY3BfT...",
  "expires_in": 3600,
  "token_type": "Bearer",
  "refresh_token": "X-OdnW0_dnQOzKmqj7Yv6S0A9lFavvg0GUMWlC3EwQA",
  "scope": "openid profile offline_access"
}
Tore Nestenius
  • 16,431
  • 5
  • 30
  • 40