Microsoft graph API: Unable to fetch users with the generated access token

后端 未结 2 450
温柔的废话
温柔的废话 2021-01-21 00:30

I have registered the application in Azure portal and i have generated the client_secret. I require the client grant flow and i have given application permissions also. I have g

2条回答
  •  一生所求
    2021-01-21 01:00

    When using the OAuth 2.0 Client Credentials Grant flow, your scope value should use the built-in .default scope for the resource your are trying to access. This is mentioned in the reference article: Microsoft identity platform and the OAuth 2.0 client credentials flow

    In your case, the resource you are trying to access is Microsoft Graph, so your scope value in the token request should be https://graph.microsoft.com/.default:

    https://login.microsoftonline.com/{tenant-id-or-domain}/oauth2/v2.0/token
        &grant_type=client_credentials
        &client_id={client-id}
        &client_secret={client-secret}
        &scope=https%3a%2f%2fgraph.microsoft.com%2f.default
    

    Note that for this to succeed, the app's required permissions must be configured (Azure portal > Azure Active Directory > App registrations > API permissions) and granted:

提交回复
热议问题