Azure B2C 声明交换可以用于访问令牌吗?

Can Azure B2C claims exchange be used for Access token?

我找到了使用自定义 REST API 向令牌添加声明的解决方法,但我意识到这是 Id 令牌而不是访问令牌。我需要将自定义声明作为访问令牌以用于在服务中进行授权。

我还没有检查访问令牌,但这些声明是否也插入到访问令牌中?

https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-custom-rest-api-netfw

我在我的 Azure Active Directory B2C 租户中使用自定义声明,我在其中注册了两个应用程序(UI 和 API)。 UI 将 access_token 传递给 API,我 能够在那里检索自定义声明 。我想这对于使用自定义 REST API 的自定义声明也应该如此。

如果没有,必须可以设置:

... The return claims can be stored in the user's Azure AD account, evaluated in the next Orchestration Steps, or included in the access token

如果你的问题是"Can I get the user's access token from the federating IdP such as Azure AD, facebook etc"?目前的答案是否定的。您可以在此处为该功能投票。

https://feedback.azure.com/forums/169401-azure-active-directory/suggestions/15334347-return-social-idp-s-native-access-tokens-back-to-t

是的,自定义声明在请求访问令牌时返回。声明列表中的唯一区别是 scp 声明。 scp 声明仅在 access tokens 返回。

遗憾的是,Claims in ID and access tokens 文档没有讨论这一点。


您可以通过 Azure 门户中的 运行 Now 功能快速验证这一点。 .

Sample access token w/ a custom claim