question

DPFY-5063 avatar image
0 Votes"
DPFY-5063 asked DPFY-5063 answered

O365 Management API certificate authentication

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://docs.microsoft.com/en-us/office/office-365-management-api/troubleshooting-the-office-365-management-activity-api


office-exchange-server-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DPFY-5063 avatar image
0 Votes"
DPFY-5063 answered

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 .

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.