Forum Discussion
Refreshing a Dataset Error 401 Unless Using access_token from Microsoft Learn
Hi WilkerFRL94 ,
Yeah, it seems like you do not have admin rights. These settings can be found in the Tenant settings. Also, it probably makes sense to create a security group with your service principal in it so they do not need to enable it for the whole organization and can manage access on a more granular level by giving API permissions only to certain service principals.
Let me know how everything goes 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
- WilkerFRL942 years agoFrequent Visitor
Right. This may take a while (and that's why usually i'll just keep searching for answers online).
I also checked a few more examples and found out that maybe i was missing the "scope" parameter when requesting the token, at the start. I set this up:
scope = "https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All/.default" # Get Access Token token_url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/token" token_data = { 'grant_type': 'client_credentials', 'client_id': client_id, 'client_secret': client_secret, 'scope': scope }And with this new token i get the 403 error code (no text) when doing the refresh POST.
I'm also wondering if it could be related to API being disabled by the tenant admin, cause with the token from the Learn page it works fine.