O365 Management API certificate authentication

DPFY 116 Reputation points
2021-10-28T16:05:33.263+00:00

I have setup a PowerShell script to read audit logs using the O365 Management API. It works well but rather than using the Azure AD app's client secret, I would prefer to use a certificate to authenticate, as is possible with MSAL.

In the documentation it only covers the app secret:

$body = @{grant_type="client_credentials";resource=$resource;client_id=$ClientID;client_secret=$ClientSecret}  
$oauth = Invoke-RestMethod -Method Post -Uri $loginURL/$tenantdomain/oauth2/token?api-version=1.0 -Body $body  
$headerParams = @{'Authorization'="$($oauth.token_type) $($oauth.access_token)"}   

ref - https://learn.microsoft.com/en-us/office/office-365-management-api/troubleshooting-the-office-365-management-activity-api

Exchange | Exchange Server | Development
0 comments No comments
{count} votes

Answer accepted by question author
  1. DPFY 116 Reputation points
    2021-11-09T16:57:42.843+00:00

    I was able to get it working, mostly by following this article: https://adamtheautomator.com/powershell-graph-api/#Acquire_an_Access_Token_Using_a_Certificate .

    0 comments No comments

0 additional answers

Sort by: Most 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.