cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
d_u_a Regular Visitor
Regular Visitor

Re: How To: Get embed token using Get/Post only

@adamwallace3 I'm sending Post request with like in your first step. But getting this error : 


"error": "invalid_request",
"error_description": "AADSTS90014: The request body must contain the following parameter: 'grant_type'.\r\

My App type is web/api in azure . Is there a solution to fix this grant_type issue? 

ezekielvp Frequent Visitor
Frequent Visitor

Re: How To: Get embed token using Get/Post only


@d_u_a wrote:

@adamwallace3 I'm sending Post request with like in your first step. But getting this error : 


"error": "invalid_request",
"error_description": "AADSTS90014: The request body must contain the following parameter: 'grant_type'.\r\

My App type is web/api in azure . Is there a solution to fix this grant_type issue? 


I used to have that error message. I tried using postman and go to the body and make sure you chose the form-data and feed the key/value needed for the request and all should work

hsheikhali Frequent Visitor
Frequent Visitor

Re: How To: Get embed token using Get/Post only

I get a nasty error saying:

400 Client Error: Bad Request for url: https://login.windows.net/common/oauth2/token
{
"timestamp": "2018-09-14 01:18:04Z",
"trace_id": "a6c902bb-2263-44ce-8675-ce1fa7196c00",
"correlation_id": "94d0a3bb-0b79-4cc9-9d52-bce7973c438e",
"error_description": "AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password\r\nTrace ID: a6c902bb-2263-44ce-8675-ce1fa7196c00\r\nCorrelation ID: 94d0a3bb-0b79-4cc9-9d52-bce7973c438e\r\nTimestamp: 2018-09-14 01:18:04Z", 01:30 Dur 21:16:15
"error": "invalid_grant",
"error_codes": [
70002,
50126
]
}

 

everytime. I registered a native app however, everytime I try to use my UserCredentials.. I get the above error... Any guidance would be great.

mohsin321 Frequent Visitor
Frequent Visitor

Re: How To: Get embed token using Get/Post only

i have successfully completed all the three steps as described in the tutorial bu at step 4 when i used my access token to generate the embed for me, HTTP gives the blank reponse there is no json array in the response as described in the tutorial and also it does not give any error .Any help regarding this issue would be appreciated thankx  

irfanharun Frequent Visitor
Frequent Visitor

Re: How To: Get embed token using Get/Post only

Hi, I've been able to complete the first 4 steps in Postman. 

However on testing the embed code in Microsoft Power BI Embedded Playground, i keep getting following error :

> Json Object { "message": "LoadReportFailed", "detailedMessage": "Fail to initialize - Could not resolve cluster", "errorCode": "403", "level": 6, "technicalDetails": { "requestId": "57679585-022b-4871-ae6d-bb722d4a07cc" } }

Also, when trying the alternative, HTML setup provided in STEP 5, i again keep getting 403 error stating : "GET https://wabi-india-west-redirect.analysis.windows.net/powerbi/globalservice/v201606/clusterdetails 403 (Forbidden)"

Please help. I've been trying to get this thing to work for over a week now.

franck_axires Frequent Visitor
Frequent Visitor

Re: How To: Get embed token using Get/Post only

Just great, thanks for sharing !

Highlighted
miliu99 Occasional Visitor
Occasional Visitor

Re: How To: Get embed token using Get/Post only

You get this "invalid_request" error probably because you simply copy/pasted data: {} into body raw. I got the same error when I did it, but got it work by copy only the key/value pairs inside the curely braces and paste it into form-data using Bulk Edit (of course enter your credentials).

jhabek Occasional Visitor
Occasional Visitor

Re: How To: Get embed token using Get/Post only

Hi there, I am trying to embed report with PHP curl. I got everything working, but when I am trying to implement row level security I got stuck.

First I get access token (this works):

 

$curl1 = curl_init();
curl_setopt_array($curl1, array(CURLOPT_URL => "https://login.windows.net/common/oauth2/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'grant_type' => 'password',
'scope' => 'openid',
'resource' => 'https://analysis.windows.net/powerbi/api',
'client_id' => '0aa12345-1234-1234-1234-123412341234', // registered App ApplicationID
'username' => 'name@domain.com', // your Power BI Pro account, e.g. john.doe@yourdomain.com
'password' => 'mysecretpassword'  // password for above user
)
));

$tokenResponse = curl_exec($curl1);
$tokenError = curl_error($curl1);

curl_close($curl1);

$tokenResult = json_decode($tokenResponse, true);
$token = $tokenResult["access_token"];
$embeddedToken = "Bearer "  . ' ' .  $token;

 

 

With this access token I should be able to create embed token with RLS for each user BUT it doesn't work:

 

$curl3 = curl_init();
curl_setopt($curl3, CURLOPT_URL, 'https://api.powerbi.com/v1.0/myorg/groups/'.$group_Id.'/reports/'.$report_ID.'/GenerateToken');
curl_setopt($curl3, CURLOPT_RETURNTRANSFER, TRUE);
//curl_setopt($curl3, CURLOPT_SSL_VERIFYPEER, false); //Might be required for https
curl_setopt($curl3, CURLOPT_ENCODING, "");
curl_setopt($curl3, CURLOPT_MAXREDIRS, 10);
curl_setopt($curl3, CURLOPT_TIMEOUT, 30);
curl_setopt($curl3, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl3, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt ($curl3, CURLOPT_HTTPHEADER,array(
    'Authorization: '.$embeddedToken,
    'Content-Type:application/json; charset=utf-8',
    'Accept:application/json',
    "accessLevel: View",
    "username: userOne",
    "roles: Tenant",
    "datasets: 12345678-1234-1234-1234-123123123"

));

$RLStokenResponse  = curl_exec($curl3);
$RLStokenError = curl_error($curl3);
curl_close($curl3);
if ($RLStokenError) {
echo "cURL Error #:" . $RLStokenError;
} else {
$RLStokenResult = json_decode($RLStokenResponse, true);
$RLStoken = $RLStokenResult["access_token"];
$RLSembeddedToken = "Bearer " . ' ' . $RLStoken;
}

 

This request returns an error. Could you please advise me what I am doing wrong?

 

skizofre3e Member
Member

Re: How To: Get embed token using Get/Post only

@aaco Did you find the source of this issue please ?

johnwhel Occasional Visitor
Occasional Visitor

Re: How To: Get embed token using Get/Post only

I am also getting a 403 Unauthorized error when I use client id and secret to access the report from Power Bi (last step).

I am able to obtain the embedded token, but not the report.

any ideas?

 

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 152 members 1,760 guests
Please welcome our newest community members: