Azure AD B2C:AcquireTokenSilentAsync返回空访问令牌

时间:2017-12-13 19:32:09

标签: azure azure-ad-b2c

我按照Create an ASP.NET web app with Azure Active Directory B2C sign-up, sign-in, profile edit, and password reset中的步骤操作,并使用示例代码为我们公司制作Azure AD B2C原型。

  • 唯一的变化是我使用了我的域名而不是示例域并修改了web.config
  • 我已经为API应用程序定义了范围和App ID
  • 我获得了Id令牌但访问令牌

有关问题的任何建议吗?

enter image description here

2 个答案:

答案 0 :(得分:2)

Create an ASP.NET web app with Azure Active Directory B2C sign-up, sign-in, profile edit, and password reset文档中缺少其中一个步骤。

the steps described here之后授予对Web应用程序的API访问权限后,将返回访问令牌。

答案 1 :(得分:0)

当我的请求的所有内容都正确时,我遇到了这个问题,除了我请求的范围。我会返回id_token,但不是access_token。我正在使用此处的示例:https://dzimchuk.net/setting-up-your-asp-net-core-2-0-apps-and-services-for-azure-ad-b2c/(顺便提一句精湛的文章)。我已经运行了应用程序但没有在Azure B2C租户中的Application Published Scopes中定义read_values范围。您描述的问题在该示例的这些代码行中表现出来。

var result = await client.AcquireTokenByAuthorizationCodeAsync(context.TokenEndpointRequest.Code, new[] { $"{authOptions.ApiIdentifier}/read_values" });

context.HandleCodeRedemption(result.AccessToken, result.IdToken); 
  

result.IdToken很好,result.AccessToken为null,直到我在我的azure b2c租户中正确定义了read_values范围。

相关问题