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

后端 未结 2 452
温柔的废话
温柔的废话 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:15

    You could try following way:

    Permission:

    Make sure you have following permission:

    Grant permission On Azure Portal:

    Step:1

    Select Application Permission On API permissions menu

    Step:2

    Select User.ReadWrite.All under Application Permission part But User.Read.All also alright.

    Token Request Format:

    URL:https://login.microsoftonline.com/YourTenant.onmicrosoft.com/oauth2/token

    For V2.0 URL:https://login.microsoftonline.com/YourTenant.onmicrosoft.com/oauth2/v2.0/token

    HTTP Verb: POST

    grant_type:client_credentials
    client_id:b603c7be-a866-4-e6921e61f925
    client_secret:Vxf1SluKbguf3wE5oGl/2XDSeZ8wL/Yp8ns4sc=
    resource:https://graph.microsoft.com
    

    For V2.0 scope Will be : scope:https://graph.microsoft.com/.default

    See the screen shot below:

    Decode Token & Confirm permission:

    You can use https://jwt.io/ to decode your token to make sure you have required permission: See the below screen shot:

    Request For User List:

    With your Token Request on this endpoint https://graph.microsoft.com/v1.0/users. See the screen shot below. I have successfully get all the user list.

提交回复
热议问题