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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Issue while generating Embed token with ClientID and login credentials using EmbedApiSample

My requirement is to use the PowerBI embedded to show the .pbix reports in a angular web application.

I'm getting the following error when I try to run this app (https://github.com/guyinacube/Embed-API-Sample) to create Embed token (as specified in the video https://www.youtube.com/watch?v=GPHHdDRSlis&list=PLv2BtOtLblH2Rm9trJPuxmN8Kr8WFv7O0&index=7). The console application is crashing when it is trying to authenticate the credentials.

{"AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'.\r\nTrace ID: 4de61335-1397-4912-ba59-62986ddc6200\r\nCorrelation ID: c7a41f92-4279-45c5-8ecf-f67dbb85d225\r\nTimestamp: 2018-04-23 15:20:09Z"}

It is breaking with the above exception when it executes the line

 authenticationResult = await authenticationContext.AcquireTokenAsync(resourceUrl, Secrets.ClientID, credential);

I Registered my application with the Power BI App Registration Tool in the link https://dev.powerbi.com/apps

I provided the following details during registration:

App Type:
    Server-side Web app
Redirect URL:
    http://localhost:4200/main/homepage
Home Page URL:
    http://localhost:4200

After registering the application with above details, I got both Client ID & Client Secret. In the console I could provide the ClientID, my login credentials, but not able to provide Client Secret. When I execute the application and during the authentication the application is crashing.

Why I am getting this error? How to generate the Embed token?

2 REPLIES 2
SuperTommy
New Member

It sounds like the request you're making has the wrong body.

To manually get an access key, see this thread for details on how to get the token using the REST API.

 

Or follow my example using Postman (free tool, use a search engine to find it).

PowerBI Access Token.png

 

In the body, fill in the client_id, username and password field with your values. For grant_type, scope and resource, copy the values in my screenshot or from the link above. Make sure POST is selected and the URL is https://login.microsoftonline.com/common/oauth2/token

Anonymous
Not applicable

Thanks for your reply. I tried following both the approaches specified by you, but both doesn't seem to work for me. not sure what is the mistake I am doing it here?
approach1: I tried calling the RestAPI service using the Restlet from chrome browser with the following data. https://login.microsoftonline.com/common/oauth2/token
{
grant_type: password
scope: openid
resource: https://analysis.windows.net/powerbi/api
client_id: ********************
username: ********************
password: ********************
}
But I am getting the error as follows:
{
"error": "invalid_request",
"error_description": "AADSTS90014: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: dea02939-adaf-44ad-9395-00dc9ba89f00\r\nCorrelation ID: d5b77411-5b4f-4858-8afd-1009ad5da0cb\r\nTimestamp: 2018-04-25 15:00:26Z",
"error_codes":[
90014
],
"timestamp": "2018-04-25 15:00:26Z",
"trace_id": "dea02939-adaf-44ad-9395-00dc9ba89f00",
"correlation_id": "d5b77411-5b4f-4858-8afd-1009ad5da0cb"
}

Approach2: With the same input data and the same RestAPI url, I tried it in Postman, but I am getting different error. 
{
"error": "invalid_grant",
"error_description": "AADSTS70002: Error validating credentials. AADSTS50056: Password does not exist in store for this user\r\nTrace ID: 57573138-e630-4813-a722-a198e5997000\r\nCorrelation ID: 46099d23-a758-446c-8b91-ed18d3b8949a\r\nTimestamp: 2018-04-25 14:54:03Z",
"error_codes": [
70002,
50056
],
"timestamp": "2018-04-25 14:54:03Z",
"trace_id": "57573138-e630-4813-a722-a198e5997000",
"correlation_id": "46099d23-a758-446c-8b91-ed18d3b8949a"
}

Please let me know what is the mistake here?

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.