Authenticate to Graph API using APIM policy

Djordje Novakovic 626 Reputation points
2023-01-09T16:05:13.327+00:00

Hello,

I am trying to configure Azure APIM policy to authenticate to Graph API and get data from Intune.

I can get it easily from powershell using App registration (ID and secret) which has API permissions to read managed devices (screenshot attached).

However, configuring APIM policy is a bit different, tried same logic as powershell uses but can't retrieve access token.

Should I use something like managed identity for this purpose?
https://learn.microsoft.com/en-us/azure/api-management/api-management-authentication-policies#ManagedIdentity

Thanks

277470-token.png

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
0 comments No comments
{count} votes

Answer accepted by question author
  1. MuthuKumaranMurugaachari-MSFT 22,446 Reputation points Moderator
    2023-01-09T19:34:43.773+00:00

    @Djordje Novakovic Thank you for reaching out to Microsoft Q&A. Yes, you are correct. authentication-managed-identity policy can be used to authenticate backend service (i.e., Graph API in your case) and refer docs for more details including examples. This way you don't need to manage client secret.

    277596-image.png

    Also, found a similar example for key vault and thought it might be helpful with your question. This example has screenshot to enable managed-identity and assigning the access policy. Feel free to add a comment if you have any other questions. We would be happy to assist you. Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Djordje Novakovic 626 Reputation points
    2023-01-10T15:45:34.567+00:00

    Thanks, I put ID of my application(which has permissions in Graph API) to this template:

    277899-1.jpg

    and I see in APIM policy log it gets Bearer token from Azure AD:

    277946-3.jpg

    I assume that now I can use that token and create new request to Graph API?

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.