我遵循了angular-oauth2-oidc库的入门指南,但它唯一存储的是nonce值,access_token不会出现在任何地方。
这是我对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
};我的app.component.ts具有以下特性:
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);
}
}在我的login.component.ts中,我有:
export class LoginComponent {
constructor(private oauthService: OAuthService) {}
login(): void { this.oauthService.initImplicitFlow();}
}在用户被重定向到这里之后,我可以在url中看到access_token等的参数。
但是当我转到localStorage时,我唯一能看到的是nonce及其值,而不是access_token。我已经尝试在控制台中打印它,并收到null。
我得到的网址是:http://localhost:4200/#access_token=thetoken&etcparams。
发布于 2019-11-22 21:30:37
@Otto Cheley你不需要添加JWK验证器。
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);
}
}尝试注释tokenValidator
https://stackoverflow.com/questions/48267493
复制相似问题