Forum Discussion
Notification when user is added to workspace
- 30 days ago
In case anyone else has a similar need, what I ended up doing was using a different endpoint and bringing back the Groups.
https://api.powerbi.com/v1.0/myorg/admin/groups?$filter=id eq 'ABCDEF-6297-4373-87a8-8978f7b7d518' or id eq 'JKLMNO-51c9-4c21-acec-96881d219116' or id eq 'KLMNOP-c4ad-4a00-9c7a-731a66755632'&$expand=users&$top=5000
I also used a different Service Principal which resolved my authorisation issues.
I added steps to filter out the authorised users and an email to notify the workspace owners in the event that any unauthorised users were found.
1. Yes based on logs you will get notified if anyone has been added to workspace
2. As per microsoft doc - Admin - Get Activity Events - REST API (Power BI Power BI REST APIs) | Microsoft Learn, When running under service prinicipal authentication, an app must not have any admin-consent required premissions for Power BI set on it in the Azure portal
So would suggest to remove Power BI service Tenant.ReadWrite.All rights
b. In Power BI tenent settings - Allow service principals to use read-only Admin APIs for service groups your service principle is part of
After making these 2 changes and try again.