cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ysapiyev Member
Member

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

Accepted Solutions
Community Support Team
Community Support Team

Re: Get token of report

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.
16 REPLIES 16
Community Support Team
Community Support Team

Re: Get token of report

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.
Community Support Team
Community Support Team

Re: Get token of report

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.
ysapiyev Member
Member

Re: Get token of report

@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

ysapiyev Member
Member

Re: Get token of report

@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

Community Support Team
Community Support Team

Re: Get token of report

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.
ysapiyev Member
Member

Re: Get token of report

@v-jiascu-msft

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

However, POST till gave me error.

 

Regards,

Yerkhan

Community Support Team
Community Support Team

Re: Get token of report

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.
ysapiyev Member
Member

Re: Get token of report

@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

Community Support Team
Community Support Team

Re: Get token of report

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.