首页 文章

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

提问于
浏览
1

我按照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令牌但 not 获取了访问令牌

关于问题可能是什么的任何建议?

enter image description here

2 回答

  • 1

    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访问权限后,将返回访问令牌 .

  • 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范围 .

相关问题