The library informs you about its tasks and state using events.
This is an Observable<OAuthEvent>
which publishes a stream of events as they occur in the service.
You can log these events to the console for debugging information.
A short snippet you could use:
this.oauthService.events.subscribe(e => console.log(e));
Or a longer, more extensive version that logs them at different levels:
import { OAuthErrorEvent } from 'angular-oauth2-oidc';
// ...
this.authService.events.subscribe(event => {
if (event instanceof OAuthErrorEvent) {
console.error(event);
} else {
console.warn(event);
}
});
Here's a list of the main events you might encounter:
discovery_document_loaded
is published whenever the service has retrieved the openid configuration and successfully saved the jwks
informationinvalid_nonce_in_state
is published during tryLogin
, when an access token has been requested and the state check was not disabled via the options, only in case the nonce is not as expected (see OAuth2 spec for more details about the nonce)user_profile_loaded
is published just before loadUserProfile()
successfully resolvestoken_received
is published whenever the requested token(s) have been successfully received and storedsilently_refreshed
is published when the silent refresh timer has gone off and the library has also successfully refreshed the tokens (only applicable to Implicit Flow)silent_refresh_timeout
is published if the silent refresh timer has gone off but it takes too long to successfully refreshsession_error
will only be published if the session checks encounter an errorFor a full list of available events see the string based enum in the file events.ts
.