【发布时间】:2020-12-17 01:35:06
【问题描述】:
我正在尝试使用 PKCE 一个 Angular 项目来实现授权代码流。我正在使用 angular-auth-oidc-client。我们已经有一个现有的基于 IdentityServer4 的内部实现,客户端可以很好地与之对抗,但我们现在正尝试将我们的身份验证迁移到 Azure AD B2C,而不是在内部实现。
我已配置 Azure AD B2C 和我的客户端应用程序。这是配置:
这是我在客户端 OIDC 服务上的配置:
oidcConfigService.withConfig({
stsServer: 'https://login.microsoftonline.com/mycompany.onmicrosoft.com/v2.0',
authWellknownEndpoint:
'https://mycompany.b2clogin.com/mycompany.onmicrosoft.com/B2C_1_SignUpSignIn/v2.0/.well-known/openid-configuration',
redirectUrl: window.location.origin,
postLogoutRedirectUri: window.location.origin,
clientId: 'client-id-guid-goes-here',
scope: 'openid profile offline_access',
responseType: 'code',
silentRenew: true,
autoUserinfo: false,
silentRenewUrl: window.location.origin + '/silent-renew.html',
logLevel: LogLevel.Debug,
renewTimeBeforeTokenExpiresInSeconds: 60
});
即使我在客户端配置中选中了 accesss_token 复选框。我在这里错过了什么?
【问题讨论】:
-
你要调用什么API?微软图形?我没有看到您为任何资源或范围请求访问令牌。只是登录吗?
-
scope: 'openid profile offline_access',未指定您要调用的 API。 -
当我在scope中指定api scope和openid时,我只收到了'id_token',没有收到access-token。我不得不从范围中删除 openid 。见docs.microsoft.com/en-us/answers/questions/135912/…
标签: openid-connect azure-ad-b2c access-token pkce angular-auth-oidc-client