我目前正在尝试在我的 Angular 应用程序中实现天蓝色广告身份验证。不幸的是,我遇到了一些问题。以下代码为我提供了我所期望的访问令牌。为了在我的 api 中实现它,我想使用 OpenIDConnect。
export class AppComponent implements OnInit {
title = 'Sign in test';
constructor(private oauthService: OAuthService) {
}
private async ConfigureAuth(): Promise<void> {
this.oauthService.configure({
loginUrl: 'loginUrl',
clientId: 'clientId',
resource: 'resource',
logoutUrl: 'logoutUrl',
redirectUri: window.location.origin + '/',
scope: 'openid',
oidc: false
});
this.oauthService.setStorage(sessionStorage);
}
async ngOnInit() {
await this.ConfigureAuth();
this.oauthService.tryLogin({});
if(!this.oauthService.getAccessToken()) {
await this.oauthService.initImplicitFlow();
}
console.log(this.oauthService.getAccessToken());
}
}
登录仍然有效,因为它给了我访问令牌,但是当我设置它时oidc
,true
它给了我以下错误:
angular-oauth2-oidc.js:1146 Error validating tokens
(anonymous) @ angular-oauth2-oidc.js:1146
Wrong issuer: https://sts.windows.net/{tenantid}/
ERROR Error: Uncaught (in promise): Wrong issuer: https://sts.windows.net/{tenantid}/
我不确定如何解决此问题,因为在这种情况下,发行人具有正确的租户 ID。
希望有人可以帮助我解决这个问题。