SOLVED

Access Office 365 Audit Logs

Copper Contributor

I have written a Powershell script to retrieve Audit Logs for Power BI, and store in SQL for analysis. The script works fine with interaction (i.e. login with username/password) but requires MFA. I cannot disable MFA for specific users, as we don't have AAD P2 or Office 365 E5, so I thought I could use an app password. It seems that this won't work either.

 

How do I access the Audit Log data, programmatically?

5 Replies

Use the Management activity API, with a service principal or a client secret: https://docs.microsoft.com/en-us/office/office-365-management-api/office-365-management-activity-api...

I did start down that path, but I couldn’t work out how the authentication works with the API. Perhaps you could help me?

I have created an App Registration in Azure, but I cannot work out how to get an OAuth token to access this particular endpoint. I get various errors.
best response confirmed by TaylorNelson (Copper Contributor)
Solution
I was on the same boat, then thought.... I should google (i mean BING!) 'How to test Graph API with Postman'.

This article walked me through how to set up the authentication process, you can even generate the code out of Postman.

https://blogs.msdn.microsoft.com/aaddevsup/2018/05/21/using-postman-to-call-the-microsoft-graph-api-...

@jerome317 

Thanks. I have actually already followed that article, and couldn't get it to work, but now I've just done it again, and it seems to work!

 

I also need to access the Power BI API, but I cannot seem to get that to work either. Do you have any experience around this?

 

Thanks

I also need to access the Power BI API, but I cannot seem to get that to work either. Do you have any experience around this?

Sadly haven't done anything yet with PowerBI.
1 best response

Accepted Solutions
best response confirmed by TaylorNelson (Copper Contributor)
Solution
I was on the same boat, then thought.... I should google (i mean BING!) 'How to test Graph API with Postman'.

This article walked me through how to set up the authentication process, you can even generate the code out of Postman.

https://blogs.msdn.microsoft.com/aaddevsup/2018/05/21/using-postman-to-call-the-microsoft-graph-api-...

View solution in original post