JamesRandall / AngularJS-OAuth2

Package for allowing an AngularJS application to authenticate with an OAuth 2 / Open ID Connect identity provider using the implicit flow.
MIT License
46 stars 42 forks source link

Ensure token is renewed at some point even after a silent-renew fails : do retries #46

Open edukey opened 7 years ago

edukey commented 7 years ago

Hi, thanks for this great lib.

When a silent renew fails for some reason (temporary broken connection or failure of the OAuth server), there is no retry made and only a full reload of the web app solves the issue (by re-executing the init process).

It will be great to have some way to ensure that, even after a silent-renew fails, other ones are tried a bit later on, via the interceptor for example but if it could be done even before a call is tried it will be better.

Possible solutions may be :

1- when we detect the current renew fails : trigger for another renew tentative after x secs 2- have a parallel regular watcher checking for token status and triggering a renew if token is null or expired or soon to expired but after the normal renew delay 3- have angular call interceptor checking for token validity and doing a silent renew if needed before the asked call, as proposed in #45

Solutions 2 and 3 made be tricky due to parallelism issues.