Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello 🙂
I already did the autentication steps and already can get the access_token. I made this using the ADAL.js
Now I'm trying to simply generate a embed token, I already got all the other informations.
With this first code, I can get the access_token, embedUrl, webUrl, reports, dashboards, groups, even groups/dashboards or reports:
ADAL.acquireToken("https://analysis.windows.net/powerbi/api",function(error, token){ access_token = token; if (error || !token) { console.log('ADAL Error Occurred: ' + error); return; } var trythis = "Bearer " + token; //alert(trythis); var request = new XMLHttpRequest(); //Parametros para selecionar o que vai ser mostrado var type = 'reports';//dashboards //var group = 'me'; var thingName = 'DashboardTeste'; request.open('GET', 'https://api.powerbi.com/v1.0/myorg/'+ type); request.setRequestHeader('Authorization', trythis); request.onreadystatechange = function (reposta) { if (this.readyState === 4) { console.log('Status:', this.status); console.log('Body:', this.responseText); handleEmbed(type,this.responseText,thingName); } }; request.send(); });
When I try to generate a Embed Token like in this code below, it returns me a 401 error:
ADAL.acquireToken("https://analysis.windows.net/powerbi/api",function(error, token){ var request = new XMLHttpRequest(); request.open('POST', 'https://api.powerbi.com/v1.0/myorg/groups/'+ groupId+'/'+type+'/'+typeId+'/GenerateToken',true); request.setRequestHeader('Content-Type','application/json; charset=utf-8'); request.setRequestHeader('Authorization', 'Bearer '+ token); request.onreadystatechange = function (reposta) { if (this.readyState === 4) { console.log('Status:', this.status); console.log('Body:', this.responseText); } }; var str = { accessLevel:"View" }; request.send(JSON.stringify(str)); });
Please, someone help me.
Solved! Go to Solution.
Hi.
You cannot use 'me' as a group for my workspace, generate token works only in groups
https://msdn.microsoft.com/en-us/library/mt784614.aspx
You can use your Pro license for developing, when you go to production, you need to purchase a capacity:
https://docs.microsoft.com/en-us/power-bi/developer/embedded-faq
Eli.
Hello @alexsilvar -
Now I'm also in the same boat.. We are embedding the reports in an application which only supports Client Side Scripting.
Did this code work for you to generate new Embed Token? If yes, could you please post here the full code..
It will be much appreciated.. Thank you.
Hi.
You cannot use 'me' as a group for my workspace, generate token works only in groups
https://msdn.microsoft.com/en-us/library/mt784614.aspx
You can use your Pro license for developing, when you go to production, you need to purchase a capacity:
https://docs.microsoft.com/en-us/power-bi/developer/embedded-faq
Eli.
Hi @alexsilvar,
Based on my test, an incorrect group_id could cause the 401 error.
If the group is correct, a fiddler capture may be required to investigate further. The required permission scope may be missing for the registered application within Azure AD. Verify the required scope is present within the app registration for Azure AD within the Azure portal.
Regards
Do you know if i can use the group 'me' as a group id? When I try it gives me the same error.
And I don't know if its relevant but I need a specific account type? (I'm using Power BI Pro)
User | Count |
---|---|
9 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
11 | |
3 | |
2 | |
2 | |
2 |