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.
Hi eprochasson,
What App Type did you choose when you register your application with the Power BI App Registration Tool? The App type selection will depend on the type of application you are using. So you may need to choose Native app in your scenario.
- Use Server-side Web app for web apps or web APIs.
- Use Native app for apps that run on client devices. You will also choose *Native app if you are embedding content for your customers regardless of what the actual application is. Even for web applications.***
As I'm not familiar with Python ADAL library and the command line you're using, could you try using Postman like below with a new created access token(either with your code or Postman) to see if the Get Group api works, in order to narrow down this issue? :smileyhappy:
Regards
- eprochasson8 years agoFrequent Visitor
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.
- eprochasson8 years agoFrequent Visitor
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.