Forum Discussion
401 when accessing any Power BI API endpoints
- 8 years ago
I found something that work and documented it (with code) here: https://bitbucket.org/omnistream/powerbi-api-example
Hopefully it would help other people in need!
It's not entirely satisfying: I'm notably not too sure why I should use this authentication endpoint instead of the one I found in other documentation, nor why I have to use a username/password on top of the app credentials, especially since it's not a super secure way to do it; I'm concerned it may get deprecated in the future. But it works.
Thanks for your help!
I used Web App. Native app doesn't allow to get a secret key for the app (apparently). I must admit the line you quote (that I read before) is quite confusing. Note that I tried with Native App before, with no success either.
I replicated (and included) the examples using Curl, which is similar to Postman.
I may have found a workaround using REST only, I'll confirm and post a solution here when it's ready. It appears the authentication method is wrong, it works if I use both application credentials AND user credentials, and negotiate the access token with
https://login.microsoftonline.com/common/oauth2/tokeninstead of
https://login.microsoftonline.com/<tenant id>/oauth2/tokenas indicated in the documentation.
None of that is properly documented so I can't explain why, it just seems to work. It works using a "Web App", and default permissions.
I found something that work and documented it (with code) here: https://bitbucket.org/omnistream/powerbi-api-example
Hopefully it would help other people in need!
It's not entirely satisfying: I'm notably not too sure why I should use this authentication endpoint instead of the one I found in other documentation, nor why I have to use a username/password on top of the app credentials, especially since it's not a super secure way to do it; I'm concerned it may get deprecated in the future. But it works.