Graph API - Insufficient privileges to complete the operation

前端 未结 9 1384
长情又很酷
长情又很酷 2020-12-09 01:37

When trying to access the Graph Service Client using I am receiving the error :

Code: Authorization_RequestDenied
Message: Insufficient privile

相关标签:
9条回答
  • 2020-12-09 02:16

    Grant permissions by ticking 'Directory.Read.All/ Write' is not enough.

    I run into the same issue. and solved by adding service principle to administrator role.

    If you application is created recently, this can be done Azure AD Powershell.

    $pricinple = Get-AzureADServicePrincipal || Where-Object {$_.DisplayName -eq 'youappname'}
    
     $role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq 'Company Administrator'}
    
    Add-AzureADDirectoryRoleMember -ObjectId $role.ObjectId -RefObjectId $pricinple.ObjectId
    

    for detail, see https://docs.microsoft.com/en-us/powershell/module/Azuread/Add-AzureADDirectoryRoleMember?view=azureadps-2.0

    If you application was created long time ago, you will need to use MSOnline. see: https://docs.microsoft.com/en-us/powershell/module/msonline/Add-MsolRoleMember?view=azureadps-1.0

    0 讨论(0)
  • 2020-12-09 02:18

    Make sure click "Grant Permissions" and than Yes for all users accounts.

    0 讨论(0)
  • 2020-12-09 02:20

    Please refer to below steps :

    1. From your screenshot , seems you grant Read and write directory data application permission for Windows Azure Active Directory(azure ad graph api) . Since you are using microsoft graph (https://graph.microsoft.com/) , you need to grant application permission for Microsoft Graph :

    2. Since you are admin in your AAD, You could grant permission for users in organization by click Grant permission button shown in above screenshot .

    3. Then you could use your code (client credential flow to get the token) and query users information . If you check the claims in access token issued by azure ad , you could find Directory.Read.All permission in roles claim .

    0 讨论(0)
提交回复
热议问题