首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >angular-oauth2-oidc未设置access_token

angular-oauth2-oidc未设置access_token
EN

Stack Overflow用户
提问于 2018-01-16 00:55:22
回答 1查看 4.2K关注 0票数 5

我遵循了angular-oauth2-oidc库的入门指南,但它唯一存储的是nonce值,access_token不会出现在任何地方。

这是我对AuthConfig的配置。

代码语言:javascript
复制
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具有以下特性:

代码语言:javascript
复制
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中,我有:

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

发布于 2019-11-22 21:30:37

@Otto Cheley你不需要添加JWK验证器。

代码语言:javascript
复制
    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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48267493

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档