Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
VikiK
New Member

Generate proper token

Hello - Looking for some direction and detailed instructions, please.
I am trying to generate a token for embedded reports in a React front end.

I have followed this article: https://medium.com/globant/how-to-embed-a-power-bi-report-in-react-f27e975e0a

I found this code: https://github.com/KotanaSai21/powerbi-embedded-React-demo/blob/main/GenerateToken.csx

I wrote a Java API for React to call in case it needed to be client->server->client thing.

 

Step 1 (in the article) will work; I get an access_token.

However, using that access_token as a bearer token in Steps 2 and Steps3 result in a 401.

(Using Postman)

Also, when using Embed Token - Generate Token - REST API (Power BI Power BI REST APIs) | Microsoft Learn,

(as also described in Step 3 of the article), it is successful from here when I "try this", but again a 401 from Postman. I notice that the Bearer Token used here in the MS Learn link is much longer than the access_token I receive in Step 1 from Postman.  Where/How does it get the Bearer Token used in the MS Learn link?

Looking for some direction on doing this programmatically, please - either via React or Java microservice - I just need it to work. 

VikiK_0-1719931683918.png

 


I am using a service principal for tenant id, along with client_id,  and client_secret, ect.
Thanks in advance-

3 REPLIES 3
VikiK
New Member

Thank you, @Ibend for your input.  Much appreciated.

We went with "embed for customers" instead of "embed for organization".  It's my understanding that "embed for organziation" uses Entra ID and each app user needs a Power BI license.  Our app owns the data and so we went with the service principal to authenticate and therefore "embed for customers".  Is that your understanding, or am I missing something?

Not exactly.   It is mostly a question if you are authenticating based on the (internal) user  SSPI or on the (external) user id (like an email address).  The license discussion is separate and depends on the SKU and the sharing method.

lbendlin
Super User
Super User

most likely you didn't ask for the right scope when creating the app in Entra ID.  Check your token's scope with jwt.io

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.