<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Generate Embed Token in pure JavaScript in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/922982#M22222</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/53674"&gt;@alexsilvar&lt;/a&gt;&amp;nbsp; -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I'm also in the same boat.. We are embedding the reports in an application which only supports Client Side Scripting.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did this code work for you to generate new Embed Token? If yes, could you please post here the full code..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will be much appreciated.. Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2020 17:07:31 GMT</pubDate>
    <dc:creator>mittalpatel130</dc:creator>
    <dc:date>2020-02-05T17:07:31Z</dc:date>
    <item>
      <title>How to Generate Embed Token in pure JavaScript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/350056#M10389</link>
      <description>&lt;P&gt;Hello &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already did the autentication steps and already can get the access_token. I&amp;nbsp;made this using the ADAL.js&lt;/P&gt;&lt;P&gt;Now I'm trying to simply generate a embed token, I already got all the other informations.&lt;/P&gt;&lt;P&gt;With this first code, I can get the access_token, embedUrl, webUrl, reports, dashboards, groups, even groups/dashboards or reports:&lt;/P&gt;&lt;PRE&gt;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();

		});&lt;/PRE&gt;&lt;P&gt;When I try to generate a Embed Token like in this code below, it returns me a 401 error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;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));		
	});&lt;/PRE&gt;&lt;P&gt;Please, someone help me.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 17:27:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/350056#M10389</guid>
      <dc:creator>alexsilvar</dc:creator>
      <dc:date>2018-02-01T17:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Generate Embed Token in pure JavaScript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/350449#M10408</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/53674"&gt;@alexsilvar&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on my test, an incorrect&amp;nbsp;&lt;SPAN&gt;group_id could&amp;nbsp;cause&amp;nbsp;the 401 error.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If the group is correct, a&amp;nbsp;fiddler capture may be required to investigate further. The &lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/register-app#apply-permissions-to-your-application-within-azure-ad" target="_self"&gt;required permission scope &lt;/A&gt;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.&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.fabric.microsoft.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 08:30:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/350449#M10408</guid>
      <dc:creator>v-ljerr-msft</dc:creator>
      <dc:date>2018-02-02T08:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to Generate Embed Token in pure JavaScript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/350671#M10415</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/11689"&gt;@v-ljerr-msft&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know if i can use the group 'me' as a group id? When I try it gives me the same error.&lt;/P&gt;&lt;P&gt;And I don't know if its relevant but I need a specific account type? (I'm using Power BI Pro)&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2018 13:01:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/350671#M10415</guid>
      <dc:creator>alexsilvar</dc:creator>
      <dc:date>2018-02-02T13:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to Generate Embed Token in pure JavaScript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/351260#M10435</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;You cannot use 'me' as a group for my workspace, generate token works only in groups&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/mt784614.aspx" target="_blank"&gt;https://msdn.microsoft.com/en-us/library/mt784614.aspx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use your Pro license for developing, when you go to production, you need to purchase a capacity:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embedded-faq" target="_blank"&gt;https://docs.microsoft.com/en-us/power-bi/developer/embedded-faq&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eli.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2018 14:37:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/351260#M10435</guid>
      <dc:creator>eligr</dc:creator>
      <dc:date>2018-02-04T14:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to Generate Embed Token in pure JavaScript</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/922982#M22222</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/53674"&gt;@alexsilvar&lt;/a&gt;&amp;nbsp; -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I'm also in the same boat.. We are embedding the reports in an application which only supports Client Side Scripting.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did this code work for you to generate new Embed Token? If yes, could you please post here the full code..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will be much appreciated.. Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2020 17:07:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/m-p/922982#M22222</guid>
      <dc:creator>mittalpatel130</dc:creator>
      <dc:date>2020-02-05T17:07:31Z</dc:date>
    </item>
  </channel>
</rss>

