azureazure-active-directorygraph-explorer

Generate access token for Listing the users of the group using graph Explorer or Postman


I am just trying to explore Azure and Graph explorer, Want to post the web application and group with users using to read the users of group. I tried but getting an error of Insufficient privileges.I am ok with both Graph Explorer or Postman use any of this

I tried but I am getting the error of insufficient privileges.


Solution

  • Error occurred as you missed granting the admin consent to the added API permissions.

    Using below HTTPS command Created an application:

    POST https://graph.microsoft.com/v1.0/applications
    Content-type: application/json
    
    {
      "displayName": "Display name"
    }
    

    enter image description here

    Created an application with default setting:

    enter image description here

    To resolve the error, add GroupMember.Read.All permission of Application type and make sure to grant admin consent.

    Granted API Permission **GroupMember.Read.All** with Admin Consent:

    enter image description here

    Now after creating application, I'll create group with adding members to it. I used below command

    POST https://graph.microsoft.com/v1.0/groups
    Content-Type: application/json
    
    {
      "description": "Group with desmembers",
      "displayName": "Testing55Group",
      "groupTypes": [
      ],
      "mailEnabled": false,
      "mailNickname": "Testing55",
      "securityEnabled": true,
    
      "members@odata.bind": [
        "https://graph.microsoft.com/v1.0/users/user1-id",
        "https://graph.microsoft.com/v1.0/users/user2-id"
      ]
    }
    By using above command, we created two members for that group.
    

    Note: Select the Members of the Group by user-id of the User.

    Now, Generating Access token using Client Credential Flow with the help of Postman,

    POST https://login.microsoftonline.com/tenantId/oauth2/v2.0/token
    grant_type:client_credentials 
    client_id:appID
    client_secret:secret 
    scope: https://graph.microsoft.com/.default
    

    Access token :

    enter image description here

    Now, listing the Members of the Group which created with the help of group-id.

    Use below command:

    https://graph.microsoft.com/v1.0/groups/group-id/members

    enter image description here

    References:

    Document Related to Group.Member.ReadAll

    List Members of Group