Forum Discussion
Is it possible to use an API Bearer to load a report preauthenticated
- 6 years ago
Hi CamStillHere ,
To summarise the steps for hte implicit grant flow with Power BI Embedded and the REST APIs:
- Prompt the user with an Azure AD account to login with its username and password
- If successfull you have an id_token
- With that id_token you can authenticate to Azure AD together with an application id
- If successfull you have an access_token
- That access_token you can use to upload the report via the Power BI REST APIs
- Use the same access_token as part of the config (together with tokenType: models.TokenType.Aad) with the Power BI Embedded SDK, see https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-overview for more information.
If I understand correctly you have already implemented the first 5 steps and you only need to implement step 6.
-JP
Hi CamStillHere ,
Do you have any update for your question? I'm happy to hear from you , to close this thread !
Unfortunately I don't have an update as I can't raise a ticket to microsoft and I haven't got an answer here as yet.
For my solution I ended up calling the browser and prompting the user to sign in (for a second time) which is a bit cumbersome but it is avoiding the problem for now. I would love to open the report with just the bearer token and I can't find a way that does this.
- jppp6 years ago
Continued Contributor
Hi CamStillHere ,
As long as your bearer token is identifying an AAD user, you can use that token with the REST APIs and to get an EmbedToken to embed a report in your application.
You can take a look at the documentation of creating an SPA application (https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-overview) with an Implicit Grant authentication schema and that usertoken you can re-use for both parts: REST API and Embedding the report.
-JP
- CamStillHere6 years agoRegular Visitor
Could you elaborate please. The answers above suggest that workflow you have mentioned would require hosting somewhere... To be clear I'd like to purely use the REST API for power bi, and load the report with that bearer.
- jppp6 years ago
Continued Contributor
HI CamStillHere ,
Big advantage of an SPA is that it doesn't need any server-side code and it can run completly in the scope of the user, like a browser with JavaScript.
-JP