1
votes

I am trying to understand how the request to the Graph API works from Azure Functions.

From the App Service of my Azure Functions, I generated the Active Directoy App, and from there, I add in the "API Permissions" to be able to do requests to the Graph API.

enter image description here

My doubts are the following:

1- When I access the endpoint of my AAD App (____.azurewebsites.net/.auth/me), could I use the access token that it returns to make the request to the Graph API? I have done some testing but it returns the following error: CompactToken parsing failed with error code: 80049217

2- I have also tried to make a request to the endpoint: https://login.microsoftonline.com/[TENANT-ID]/oauth2/v2.0/token so that it should return an access token to make the request to the API of Graph. But I am getting the next error: The request body must contain the following parameter: 'grant_type'

To do this tries, I am using Postman/Insomnia. But I am not very sure how to continue trying.

Thanks beforehand

1

1 Answers

1
votes

1- When I access the endpoint of my AAD App (____.azurewebsites.net/.auth/me), could I use the access token that it returns to make the request to the Graph API?

Yes, you can. You need to add ["resource=https://graph.microsoft.com"] to additionalLoginParams under authsettings. Refer to this blog for more details.

enter image description here

2- I have also tried to make a request to the endpoint: https://login.microsoftonline.com/[TENANT-ID]/oauth2/v2.0/token so that it should return an access token to make the request to the API of Graph. But I am getting the next error: The request body must contain the following parameter: 'grant_type'

To call this endpoint, you will need some parameters, refer to this article for more details.

Another thing is that there are two kinds of API permissions, Delegated permission and Application permission. You should use Delegated permission instead of Application permission.

Reference:

Difference between Azure App Registration -‘Delegated’ and ‘Application’ Permission