angular-oauth2-oidc未设置访问令牌
我遵循angular-oauth2-oidc库的入门指南,但它存储的唯一内容是angular-oauth2-oidc未设置访问令牌,angular,oauth-2.0,azure-active-directory,openid,angular-oauth2-oidc,Angular,Oauth 2.0,Azure Active Directory,Openid,Angular Oauth2 Oidc,我遵循angular-oauth2-oidc库的入门指南,但它存储的唯一内容是nonce值,而access\u令牌在任何地方都不会出现 这是我对AuthConfig的配置 export const AUTHCONFIG:AUTHCONFIG={ 罗吉努尔:'https://login.microsoftonline.com/xxxxxxxx/oauth2/authorize', 重定向URI:window.location.origin+'/',//localhost:4200/ clientI
nonce
值,而access\u令牌在任何地方都不会出现
这是我对AuthConfig
的配置
export const AUTHCONFIG:AUTHCONFIG={
罗吉努尔:'https://login.microsoftonline.com/xxxxxxxx/oauth2/authorize',
重定向URI:window.location.origin+'/',//localhost:4200/
clientId:“我在azure中注册的angular应用程序的id”,
resource:'我在nodejs中的web api的id也已注册',
是的,
requireHttps:false//这是用于在本地主机中进行测试的
};
Myapp.component.ts
具有以下功能:
导出类AppComponent{
构造函数(私有oauthService:oauthService){this.loadConfig()}
loadConfig():void{
this.ouathService.configure(AUTHCONFIG);
this.ouathService.tokenValidationHandler
=新的JwksValidationHandler();
this.ouathService.token.setStorage(localStorage);
}
}
在我的login.component.ts
中,我有:
导出类登录组件{
构造函数(专用oauthService:oauthService){}
login():void{this.oauthService.initImplicitFlow();}
}
在用户被重定向到这里之后,我可以在url中看到访问令牌等的参数
但是,当我转到localStorage时,我唯一能看到的是nonce
及其值,而不是access\u令牌。我已经尝试在控制台中打印它,我收到null
这是我返回的url:http://localhost:4200/#access_token=thetoken&etcparams
@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);
}
}
尝试使用commenting tokenValidator您确定该库与Azure AD兼容吗?@juunas是的,我看过本教程。我已经解决了我的问题,现在我可以看到access_令牌,我有一个新的错误,它说我有一个错误的颁发者,所以它无法验证令牌。我将我的issuer属性设置为,但它一直说这是一个错误的issuer。错误在哪里?您是如何修复的?从登录页面返回后,我也无法访问令牌-即使它在url中被设置为参数。@错误是我没有在AuthConfig中设置issuer和jwks属性,这显然是正常工作所必需的,一旦你填充了这些道具,它应该很好用:)对你朋友有用吗?