I was following the getting-started guide for the angular-oauth2-oidc library, but the only thing it stores is the nonce
value, the access_token
doesn't appear anywhere.
This is the configuration I have for AuthConfig
.
export const AUTHCONFIG: AuthConfig = {
loginUrl: 'https://login.microsoftonline.com/xxxxxxxx/oauth2/authorize',
redirectUri: window.location.origin + '/', //localhost:4200/
clientId: 'the id of my angular app registered in azure',
resource: 'the id of my web api in nodejs also registered',
oidc: true,
requireHttps: false // this is for testing in localhost
};
My app.component.ts
has the following:
export class AppComponent {
constructor(private oauthService: OAuthService) {this.loadConfig()}
loadConfig(): void {
this.ouathService.configure(AUTHCONFIG);
this.ouathService.tokenValidationHandler
= new JwksValidationHandler();
this.ouathService.token.setStorage(localStorage);
}
}
In my login.component.ts
I have:
export class LoginComponent {
constructor(private oauthService: OAuthService) {}
login(): void { this.oauthService.initImplicitFlow();}
}
After the user gets redirected here, I can see in the url the params of access_token and etc.
But when I go to localStorage the only thing I can see is nonce
and its value, but not the access_token
. I've already tried to print it in the console and I receive null
.
This the url I get back: http://localhost:4200/#access_token=thetoken&etcparams
.