上下文
我知道Azure AD B2C在oauth2 client_credentials流上有一个限制,但我已经看到可以再次请求AD令牌,而不是AD B2C。
据我了解,这是对权限域的更改,所以不要使用:
https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{policy}/oauth2/v2.0/token我们应该使用:
https://login.microsoftonline.com/032bba1a-4a23-41d0-8713-69ad1a38cf69/oauth2/v2.0/token问题
我的问题是,如果我向其添加一个作用域,比如https://graph.microsoft.com/openid/.default或其他来自不同应用程序(这是我打算使用的应用程序) https://{tenant}.onmicrosoft.com/backendtestapi/api/.default的作用域,我就会得到以下错误:
AADSTS500011: The resource principal named https://graph.microsoft.com/openid was not found in the tenant named xxxxx-xxxxx-xxxxx-xxxxx. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant如果我请求这个作用域,我不明白为什么会出现错误。有人能指点我吗?
非常感谢!
发布于 2021-05-18 01:33:27
请注意,Microsoft是官方的API,其scope为V2.0有固定的写入格式https://graph.microsoft.com/.default。
将https://graph.microsoft.com/openid/.default更改为https://graph.microsoft.com/.default可以解决此问题,您将获得一个用于调用Microsoft的访问令牌。
如果您有自己的自定义Web (需要客户端凭据流),则应该通过遵循公开应用程序权限(应用程序角色)在API应用程序注册中公开该API。然后通过以下添加访问web API的权限在客户端应用程序注册中配置应用程序权限。
在此之后,您可以获得scope格式。通常是api://{app id of the API app registration}/.default。如果您将API注册的应用程序ID URI自定义为https://{tenant}.onmicrosoft.com/backendtestapi/api/,那么scope应该是https://{tenant}.onmicrosoft.com/backendtestapi/api/.default。
但有一件重要的事情你需要明白。因为客户端凭据流在没有用户的情况下发出应用程序令牌,所以在本例中它与B2C身份验证无关。换句话说,您只需“借用”B2C租户来创建应用程序注册。B2C不用于身份验证。
顺便说一句,申请许可通常需要行政许可。不要忘记在客户端应用程序注册或使用“管理员同意”端点上单击“为{您的租户}授予管理许可”来执行此操作。
https://stackoverflow.com/questions/67573829
复制相似问题