angular-oauth2-oidc token always invalid after log in


I am trying to follow the guide on the documentation

I have the following config in my constructor for the service:

authCodeFlowConfig: AuthConfig = {
   issuer: '',
   redirectUri: window.location.origin + '/home',
   clientId: 'spa',
   responseType: 'code',
   scope: 'openid profile email offline_access api',
   showDebugInformation: true


(i have also tried with a redirect url of index.html but that didnt seem to make a difference)

Logging in seems to work just fine i get the redirect to the page log in and get redirected home:

    this.oauthService.loadDiscoveryDocumentAndTryLogin().then((response) => {
      if (!this.oauthService.hasValidIdToken() || !this.oauthService.hasValidAccessToken()) {
    }).catch((err) => {

However the following still returns false, false, null:

    const claims = this.oauthService.getIdentityClaims();

I have a code= in my url have no other changes to the service and everything seems to have logged me in.
I’m expecting to have done something stupid or misunderstood what is going on but any advice would be helpful.


Turns out i wasn’t doing it correctly.

I wasn’t calling the load discovery document in my constructor as i should have done.

If the page reloads i dont have the discovery document to check my token against and hence it is invalid.

Answered By – Damian Fox

Answer Checked By – Robin (AngularFixing Admin)

Leave a Reply

Your email address will not be published.