M365 Microsoft Graph API - Client Credentials Flow

Hi All, I want to use the Microsoft Graph API for workflow. I have been successfully using the resource for Apps but the authentication method isn't compatible with Workflows.

I tried the approach in Get access without a user - Microsoft Graph | Microsoft Learn using OAuth2.0 and client credentials flow but I could not get it to get/send the bearer token correctly.

After much to-ing and fro-ing I settled on:

  1. Providing the Admin consent MS requires for the app permissions directly in the Azure portal
  2. Using Custom Auth with the following steps:
    i. API call to
    POST 'Sign in to your account'
    --header 'Content-Type: application/x-www-form-urlencoded'
    --data-urlencode 'client_id=YOURCLIENTID'
    --data-urlencode 'scope=https://graph.microsoft.com/.default'
    --data-urlencode 'client_secret=YOURCLIENTSECRET'
    --data-urlencode 'grant_type=client_credentials'
    ii. Define Variable to extract the token from {{http1.body.access_token}} to pass when calling the API.

Hope this helps others.

2 Likes