Getting MS Authentication Token using a Logic App

Dhruv | Oct 10, 2021

Often we need to get an access token for Microsoft Graph API and other MS services. This can be done using OAUTH REST API provided by MS. This is not at all a complex task but I have made it and encapsulated it in a logic app which can be deployed and then configured with necessary details to get the access token.

Deployment

Deploy to Azure

  • Go to Microsoft Authentication API and then click on Deploy to Azure.
  • A custom deployment screen will open in Azure. Fill out all the necessary details and click on Review + Create and then click on Create to finally deploy the template.
  • Click on Go To Resource. The logic app will open.
  • Click on Edit to open the logic app in Logic App Designer.

Variable updates

  • Change the Variables:
    • TenantID
    • ClientID
    • ClientSecret
    • VerificationID
  • Client ID and ClientSecret will be the details of the application registered in Azure AD and have been granted permission to Graph API.
  • VerificationID is just any string that can be added here. You will need to pass it in your HTTP request along with scope.

HTTP Request

{
“verifyId”:”TemporaryVerifyID”,
“scope”: “https://graph.microsoft.com/.default”
}
  • When a POST request is sent to the new logic app that is created, you will get an access token in response. You can try it in Postman.

SAMPLE Response

{
“token”: “eyJ0eXAiO”
}