The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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)
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
2 | |
1 | |
1 | |
1 |