1

I have a React app where I'm embedding a PowerBI service report with user-owns-data (aka embed-for-organization) method with the help of powerbi-client-React library. like follow.

<PowerBIEmbed
  embedConfig = {{
    type: "report",   // Supported types: report, dashboard, tile, visual and qna
    id: "281839f6-4971-4ad3rtt",
    tokenType: models.TokenType.Aad
    accessToken : "938orie90rekjd-9393"
     ....some more properties here....
  />

where, models object is imported from powerbi-client library, and <PowerBiEmbed/> from 'powerbi-client-react (dependency).

Currently to get that 'azure ad access token' what I'm doing is-

  1. Signing into my PowerBI account
  2. Going to the browser console, and doing copy(powerbiaccesstoken) and I get my token.
  3. I go into my code and paste it there.

So, now the report is embedded in my React app for at least 1 hour, because that token is only valid for one hour. Thereafter it shows a prompt for the user to sign in with their PowerBI credentials.

sign into PowerBI popup while embedding report

Now I have to sign into my PowerBI account again, copy the AAD token, and paste it into my code.

I have a dedicated PowerBI Pro account whose credentials can be used in creating access tokens.

Is there a way for me to do this without copying the token repeatedly? And some JavaScript code on either front-end or back-end do this for me before the access token really expires?

1 Answer 1

0

And some javascript code on either front-end or backend do this for me before the access token really expires?

Yes. This must be done from the back-end, as you can't expose the master user credentials to the client. Follow the docs here to get the access token for your master user, and create the embed token from a back-end service.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.