Skip to content

Token refresh error after being idle for few hours #1156

Open
@santosmken

Description

@santosmken

Describe the bug
When I already had a successful http request and I set my device to (hibernate | sleep | shutdown) mode then I went back again to the web-app which I didn't close and make another http request, the token that is being sent to the api is not valid always. As a result, I got 401 every time and I have to reload the page to get a valid token from my IDp. Is there a proper way to handle it like via interceptor?

To Reproduce
Steps to reproduce the behavior:

  1. Go to the web-app and do some http call
  2. Shutdown or sleep or hibernate your device like an hour or less
  3. Go back to the web-app and do another http call
  4. IDp (Azure B2C) in my case returns "token_refresh_error" and as a result, the http request is always 401 unauthorized

Expected behavior
The incoming request after being idle for few hours should be valid and must be renew first before the actual http call since I provided the "allowedUrls" from the forRoot and enabled sendAcessToken.

Desktop (please complete the following information):

  • OS: any
  • Browser: any
  • Version: Latest

Additional context
The provided scope are:

  1. openid b2cClientId
  2. oidc: true
  3. strictDiscoveryDocumentValidation: false

In my APP_INITIALIZER, the steps I have are the ff:

  1. Load discovery document and tryLogin()
  2. Check if hasValidAccessToken. If true, I invoke setupAutomaticSilentRefresh() then resolve the Promise.
  3. When false, I invoke initCodeFlow then reject the Promise

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugFor tagging faulty or unexpected behavior.investigation-neededIndication that the maintainer or involved community members may need to investigate more.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions