IdentityModel / oidc-client-js

OpenID Connect (OIDC) and OAuth2 protocol support for browser-based JavaScript applications
Apache License 2.0
2.43k stars 841 forks source link

Are there any events fired when the session is checked by the oidc client? #1245

Closed blueelvis closed 3 years ago

blueelvis commented 4 years ago

Hi,

My current scenario is as below (I have implemented oidc-client-js successfully with PKCE with Azure AD) -

  1. Open the web app (it is a SPA) and let it authenticate and authorize.
  2. The token is saved and is now valid for 1 hour.

My question is that, suppose I turn off my machine for 2.5 hours and then resume the state of the machine. The token in the cache is now stale. Since there is no event which is fired (I have hooked to the tokenExpiring notification), I see that the web app fails making API calls.

I see that there is an optional setting of checkSessionInterval in the wiki. Is there any event which is fired by this checkSession which I can hook into so that when it detects that the session is invalid, I can do an immediate silent sign in?

Open to other suggestions & thoughts as well :)

Thanks!

Powersource commented 3 years ago

You could pass automaticSilentRenew: true to the userManager instead?

Powersource commented 3 years ago

But yeah I think I might like an event for this too. I'd like to know when to start using a new token.

brockallen commented 3 years ago

The userLoaded event fires when the silent renew updates the storage with a new user object (and token).