简体   繁体   English

Microsoft Graph API 角色声明未在令牌中但已添加应用程序权限

[英]Microsoft Graph API roles claim not in token but Application permissions added

I'm attempting to connect to the Microsoft Graph API to use an excel function, as a server to server connection/flow.我正在尝试连接到 Microsoft Graph API 以使用 excel function 作为服务器到服务器的连接/流。 https://learn.microsoft.com/en-us/graph/excel-use-functions https://learn.microsoft.com/en-us/graph/excel-use-functions

In Azure AD I've built the registered application:在 Azure AD 中,我构建了注册应用程序:天蓝色注册的应用程序

I've created the secret...and also added the API Permissions.我已经创建了秘密...并且还添加了 API 权限。应用权限

In Postman, I'm able to get the token fine.....but I notice that roles are not included in the token.在 Postman 中,我能够很好地获得令牌......但我注意到令牌中不包含角色。 Here's the request:这是请求:令牌请求

And then when I make a request to the excel function of RATE I get this error:然后当我向 RATE 的 excel function 发出请求时,我收到此错误:

{
    "error": {
        "code": "AccessDenied",
        "message": "Either scp or roles claim need to be present in the token.",
        "innerError": {
            "date": "2021-08-17T14:31:04",
            "request-id": "b0d65e3c-4acd-4a8a-82c4-1c4c5f2216ac",
            "client-request-id": "b0d65e3c-4acd-4a8a-82c4-1c4c5f2216ac"
        }
    }
}

Every post I still on here mentions API permissions and granting consent as Admin....which I have completed but I'm still getting the error.我仍然在这里的每篇文章都提到了 API 权限并以管理员身份授予同意....我已经完成但我仍然收到错误。 Any thoughts?有什么想法吗?

Please check if there is any claims mapping policy linked to the application service principal.请检查是否有任何声明映射策略链接到应用程序服务主体。

  1. Navigate to Azure Active Directory > Enterprise Applications > Search with the Client ID you used in your token request > copy the object ID of the app.导航到 Azure Active Directory > 企业应用程序 > 使用您在令牌请求中使用的客户端 ID 进行搜索 > 复制应用程序的 object ID。 Keep in mind that this object id is different than the object ID of the application object present under App Registration.请记住,此 object ID 不同于 App Registration 下应用程序 object 的 object ID。
  2. Run Get-AzureADServicePrincipalPolicy -Id object_id_copied_in_step_1 | fl运行Get-AzureADServicePrincipalPolicy -Id object_id_copied_in_step_1 | fl Get-AzureADServicePrincipalPolicy -Id object_id_copied_in_step_1 | fl to check if there is any claims mapping policy linked. Get-AzureADServicePrincipalPolicy -Id object_id_copied_in_step_1 | fl检查是否有链接的声明映射策略。
  3. If there is a cliams mapping policy linked to it, run Remove-AzureADServicePrincipalPolicy to remove the policy.如果有链接到它的 cliams 映射策略,请运行Remove-AzureADServicePrincipalPolicy以删除该策略。

Decode your bearer token at https://jwt.ms to confirm if the Roles claim is populated or not.https://jwt.ms解码您的不记名令牌以确认 Roles 声明是否已填充。 SCP claim will not be populated in this case, as it only populates when the token is acquired under user context.在这种情况下不会填充 SCP 声明,因为它只会在用户上下文中获取令牌时填充。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获取委托权限的令牌(Microsoft Graph) - How to acquire token for delegated permissions (microsoft graph) Microsoft graph API:应用程序权限授予(应用程序角色)(不通过 Oauth2PermissionGrants 委托) - Microsoft graph API: permission grant for application (app roles) (NOT delegate via Oauth2PermissionGrants) Microsoft Graph API 应用程序 Collections - Microsoft Graph API Application Collections Azure AD:通过 AAD 在 jwt 令牌中缺少角色声明 - Azure AD: missing roles claim in jwt token through AAD Microsoft Office Graph API 刷新令牌的有效期有多长? - How long does Microsoft Office Graph API refresh token lives? Azure Active Directory 中供应用程序使用的角色和权限 - Roles & Permissions in Azure Active Directory for Application Use 通过图 Api 在 Azure ADB2C 中添加自定义声明 - Add custom claim in Azure ADB2C through Graph Api 如何在没有企业应用程序客户端密钥的情况下刷新 Microsoft Graph API 的令牌? - How to refresh the token of Microsoft Graph API without Client Secret for an Enterprise App? 无法使用 Microsoft graph API 和 Java Spring 获取带有授权码的令牌 - Failed to acquire token with authorization code using Microsoft graph API with Java Spring Microsoft Graph:我是否可以(重新)使用 AAD 转发的用户 Bearer Token 以便对 Graph API 进行“委托”调用? - Microsoft Graph: Can I (re)use the user's Bearer Token forwarded by AAD in order to make "delegated" calls to the Graph API?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM