我正在关注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 .