Search code examples
azure-active-directory

Want to generate a token for accessing the application with associated users information from a particular tenant


I am new to Azure Portal,I have premium p2 subscription, I want to generate a token using Client Credentials flow type, Basically want to read my application and users associated with my Tenant. I am using Postman for calling API.

I tried but not able to achieve desired output.I am confused with which API should I call.


Solution

  • Created an Microsoft Entra ID Application like below:

    enter image description here

    Note: If you want to read all users and applications of tenant , Add permissionUser.Read.All and Application.Read.All.

    Adding Application.Read.All and User.Read.All like below:

    enter image description here

    Now you need to generate Access Token by Postman

    GET https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token
    
    client_id: <application id>
    client_secret: <client secret>
    grant_type: client_credentials
    scope: https://graph.microsoft.com/.default
    
    

    Generated Access Token:

    enter image description here

    After Successfully generating access token, Now use the Access token to list Users and Application in Tenant.

    1. List the User

    GET https://graph.microsoft.com/v1.0/users

    enter image description here

    2.List the Applications

    GET https://graph.microsoft.com/v1.0/applications

    enter image description here

    References:

    List the Users

    List the Applications