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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ysapiyev
Responsive Resident
Responsive Resident

Get token of report

Hi everyone

 

I have a question regarding embed token of report to insert it in Azure web app.

Currently, I followed video instruction from Guy in cube regarding getting token and I got error.

Also, I followed instructions for getting token with function app, and also got compile error.

Is there another way to get token? Also, does it require Power BI embedded to embed it?

 

Regards,

Yerkhan

1 ACCEPTED SOLUTION

Hi Yerkhan,

 

Regarding the error, please refer to #grant-admin-consent-to-enterprise-apps-in-the-azure-portal for a solution. Please also refer to the snapshot below.

Get-token-of-report

 

In order to get the embed token, we need to get a valid access token first, then invoke the REST API with it to get the embed token. Please refer to the snapshots below.

1. Get an access token.

POST https://login.microsoftonline.com/replace_with_your_tenant_id/oauth2/token
resource: https://analysis.windows.net/powerbi/api

Get-token-of-report2

2. Invoke the "generate embed token" API.

Get-token-of-report3

If there aren't any roles, you don't need to specify the identities.

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

16 REPLIES 16
NEbdf
Frequent Visitor

Greetings,

first of all, thanks for the detailed instructions @v-jiascu-msft. But I am still struggling to get this to work in Postman. I followed each of your described steps, but only get the following error message in return:

{
    "error": "invalid_grant",
    "error_description": "AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password\r\nTrace ID: dba5dbef-834c-4df0-910f-2ad7e6e23600\r\nCorrelation ID: ee8fa976-7366-4056-9523-b5d1c606c78f\r\nTimestamp: 2019-01-09 08:14:06Z",
    "error_codes": [
        70002,
        50126
    ],
    "timestamp": "2019-01-09 08:14:06Z",
    "trace_id": "dba5dbef-834c-4df0-910f-2ad7e6e23600",
    "correlation_id": "ee8fa976-7366-4056-9523-b5d1c606c78f"
}

I of course double checked every key/value, URL and the App Settings in Azure. I also used the PowerBI embed configuration tool to setup the environment in Azure. The generated .net application also generates a token sucessfully (but I need it with a simple post call) so I am sure that the used credentials are working.

Do you maybe have some more ideas what else I can try? Or are there maybe basic configurations in Azure which could prevent a successful post call of Postman?

Thanks!

Hi @NEbdf,

 

Since you can use the password to get token with .net application, that's hard to say what went wrong. Can you share a snapshot of how you did it? Please mask the sensitive parts.

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Sure. Here is the latest Postman configuration:

postmanPowerBI.jpg

Hi @NEbdf,

 

All seems good. If it's a web app, the client_secret is needed. But the error message shouldn't be this one. 

If I use a wrong password, I got the same error message. I would suggest you check the username and password again though it sounds impossible. Maybe you have multi-tenant?

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 Hi @v-jiascu-msft

the app in Azure is configured as a native app. Seems to be the default when using the PowerBI configurator. Should PowerBI embed also work when its a Web-App/API?

Edit:
Just tested everything with seting up a Web-App/API and delivering the app secret. Same error message as before unfortunately.

Hi @NEbdf,

 

That's too weird. I would suggest you file a support ticket here. I will appreciate it if you can share the cause and the solution. 

create-ATicket

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Employee
Employee

Hi Yerkhan,

 

Could you please mark the proper answers as solutions?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-jiascu-msft

 

I've also tried to use POST. I made request in POSTMAN application, however I got empty body request as response.

 

I used following approach:

https://api.powerbi.com/v1.0/myorg/groups/{group-id}/reports/{report-id}/GenerateToken

and following body:

{
  "accessLevel": "View",
  "identities": [
    {
      "username": "{username}",
      "datasets": [
        "{dataset-id}"
      ]
    }
  ]
}

What can be my mistake?

 

Regards,

Yerkhan

v-jiascu-msft
Employee
Employee

Hi Yerkhan,

 

What's the error message? You can download the program from Embed-API-Sample

You also can request the embed token using rest/api/power-bi/embedtoken.

 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-jiascu-msft

 

Hi, Dale,

 

I've tried embed sample, and got this error:

 The user or administrator has not consented to use the application with ID.  Send an interactive authorization request for this user and resource.

 

So, does it mean that I need to send request to administrator of AD?

 

Regards,

Yerkhan

Hi Yerkhan,

 

Regarding the error, please refer to #grant-admin-consent-to-enterprise-apps-in-the-azure-portal for a solution. Please also refer to the snapshot below.

Get-token-of-report

 

In order to get the embed token, we need to get a valid access token first, then invoke the REST API with it to get the embed token. Please refer to the snapshots below.

1. Get an access token.

POST https://login.microsoftonline.com/replace_with_your_tenant_id/oauth2/token
resource: https://analysis.windows.net/powerbi/api

Get-token-of-report2

2. Invoke the "generate embed token" API.

Get-token-of-report3

If there aren't any roles, you don't need to specify the identities.

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-jiascu-msft

Thanks. I was able to get embed token by granting permission.

However, POST till gave me error.

 

Regards,

Yerkhan

Hi Yerkhan,

 

What's error message exactly?

 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-jiascu-msft

 

Here is error:

Tenant name 'replace_with_your_tenant_id' specified is not a valid DNS name and not valid external domain format

 

Regards,

Yerkhan

Hi Yerkhan,

 

I should have made that clear. The 'replace_with_your_tenant_id' is your tenant ID. Please refer to the snapshot below.

https://login.microsoftonline.com/replace_with_your_tenant_id/oauth2/token

Get-token-of-report4

 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-jiascu-msft

 

Thanks, it was an issue. 

 

Regards,

Yerkhan

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.