0
votes

I have registered an application on Azure AD and created 2 users and a group in the azure ad directory using the azure portal. Now through Microsoft Graph explorer , I am testing the API for the operation "Get All user groups is the organization", but I am getting empty array as response though there exists a group on the AD in my directory.

For the operation "Get the groups I belong to", I get error.

I have followed the documentation, and as I understand we need to first request an access token to make calls to other APIs like fetching user groups etc. I followed the steps as mentioned in the link: https://docs.microsoft.com/en-us/graph/auth-v2-service?view=graph-rest-1.0#4-get-an-access-token to request the access token.

I have fired a query from graph explorer, and details are:

1) Specified the endpoint as: https://login.microsoftonline.com/[TENANTID]/oauth2/v2.0/token

2) Specified request header with content type : application/x-www-form-urlencoded

3) Sent the request body in json

4) Given application permissions and also granted the admin consent using the Azure portal.

I have carefully rechecked the client ID, tenant ID, scope, secret and other creds again. But on making the API call I don't receive any response.

JSON body to request access token:

{
    "client_id": "[clientId]",
    "scope": "https://graph.microsoft.com/.default",
    "client_secret": "[the-secret]",
    "grant_type": "client_credentials"
}

Expected result: I should get a json response with "Bearer" token in it.

Actual result:There is no response from Azure , and the request is shown a s processing.

In which direction should I see to solve the problem? I found a similar question here: **Where can I find APP ID URI for Microsoft App? **. But my problem is still unsolved.

Screenshot showing the request and response: enter image description here

Screenshot showing the group in azure ad: enter image description here

1
I'm confused. Your question asks about Bearer tokens but the screenshot shows Groups in Graph Explorer. Is your question about Bearer Tokens, Microsoft Graph, or Graph Explorer? They are 3 different things.Marc LaFleur
Okay,let me explain. So my ultimate aim is to make calls to APIs like "Fetching user groups", "Fetching the group to which a user belongs" etc from the graph explorer. But, according to the documentation, we have to request and get a access token(Bearer token) first to make these API calls. So I tried to fetch token by calling /token endpoint from graph explorer, but didn't get any response.So asked the question on stack overflow. Now as Allen Wu answered, when using graph explorer we dont need to fetch the token to make API calls, and we can directly call the API to fetch all groups.Ayush
But the API call to fetch all groups is also not returning me the result, when making the call through graph explorer. So this is my problem. But let me also tell you that token fetching and group fetching is working through postman.Ayush

1 Answers

1
votes

The Microsoft Graph explorer is a tool that lets you make requests and see responses against the Microsoft Graph. It will get an access token for you automatically before you call Graph endpoint. Do not use it to call endpoints other than Graph.

Your process should be OK. But you should choose other tools such as Postman, Talend API TESTER.


Update:

enter image description here