<?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: Getting PowerBI embed Access Token via REST in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Getting-PowerBI-embed-Access-Token-via-REST/m-p/405856#M12101</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/57263"&gt;@eddywijaya&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe &lt;A href="https://community.powerbi.com/t5/Developer/How-To-Get-embed-token-using-Get-Post-only/m-p/294475" target="_blank"&gt;this previous post&lt;/A&gt; solves your problem?&lt;/P&gt;&lt;P&gt;Otherwise, could you try something like this using .NET code in order to see that it works? Does it returns a token?&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this token you can then make calls to the PowerBI REST API using Fiddler/Postman.&lt;/P&gt;&lt;P&gt;Note that the AAD application should be a &lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/register-app" target="_blank"&gt;native app&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using Microsoft.IdentityModel.Clients.ActiveDirectory;&lt;BR /&gt;&lt;BR /&gt;/// &amp;lt;summary&amp;gt;
/// Returns an AccessToken for the PowerBi service.
/// &amp;lt;/summary&amp;gt;
private async Task&amp;lt;string&amp;gt; GetPowerBiAccessToken()
{
	var powerBiAccountCredentials = new UserCredential("PowerBIAADUserName", PowerBIAADUserPassword");
	var authenticationContext = new AuthenticationContext("https://login.windows.net/common/oauth2/authorize/");
	var authenticationResult = await authenticationContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", "PowerBIAADAppId", powerBiAccountCredentials);

	return authenticationResult.AccessToken;
}&lt;/PRE&gt;&lt;P&gt;This link about &lt;A href="https://docs.microsoft.com/en-us/rest/api/datacatalog/authenticate-a-client-app" target="_blank"&gt;authenticate a client app&lt;/A&gt; may be helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanos&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Apr 2018 09:33:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-04-27T09:33:14Z</dc:date>
    <item>
      <title>Getting PowerBI embed Access Token via REST</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Getting-PowerBI-embed-Access-Token-via-REST/m-p/405673#M12096</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Hi everyone,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I'm creating a PowerBI embedded App&amp;nbsp;following this Sample :&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;A href="https://github.com/Microsoft/PowerBI-Developer-Samples/tree/master/User%20Owns%20Data/integrate-dashboard-web-app" target="_self"&gt;https://github.com/Microsoft/PowerBI-Developer-Samples/tree/master/User%20Owns%20Data/integrate-dashboard-web-app&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;But i'd like to use a service account, so the user can access the dashboard without signing in to Microsoft. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;So i tried to get the access token from :&amp;nbsp;&lt;A href="https://login.windows.net/common/oauth2/token" target="_self"&gt;https://login.windows.net/common/oauth2/token&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;This is the example screenshot (i'm using Postman)&amp;nbsp;&lt;A href="https://drive.google.com/file/d/12hh3Knpei1GNsMMwnYBfAycfvzwklTon/view?usp=sharing" target="_self"&gt;POST image&lt;/A&gt;, and i'm getting this error :&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;{
    "error": "invalid_grant",
    "error_description": "AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password\r\nTrace ID: 3651fe1c-cfec-45a9-bef4-1aa7b0140400\r\nCorrelation ID: 1f661718-738e-4654-97ce-b8388ac01401\r\nTimestamp: 2018-04-27 02:32:33Z",
    "error_codes": [
        70002,
        50126
    ],
    "timestamp": "2018-04-27 02:32:33Z",
    "trace_id": "3651fe1c-cfec-45a9-bef4-1aa7b0140400",
    "correlation_id": "1f661718-738e-4654-97ce-b8388ac01401"
}&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT size="2"&gt;I'm sure that i have given the correct credential (username, password, client_id, client_secret) because they're working in the .NET sample project.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;There is no symbol on the password, only alphabetical and number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 06:24:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Getting-PowerBI-embed-Access-Token-via-REST/m-p/405673#M12096</guid>
      <dc:creator>eddywijaya</dc:creator>
      <dc:date>2018-04-27T06:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Getting PowerBI embed Access Token via REST</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Getting-PowerBI-embed-Access-Token-via-REST/m-p/405856#M12101</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/57263"&gt;@eddywijaya&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe &lt;A href="https://community.powerbi.com/t5/Developer/How-To-Get-embed-token-using-Get-Post-only/m-p/294475" target="_blank"&gt;this previous post&lt;/A&gt; solves your problem?&lt;/P&gt;&lt;P&gt;Otherwise, could you try something like this using .NET code in order to see that it works? Does it returns a token?&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this token you can then make calls to the PowerBI REST API using Fiddler/Postman.&lt;/P&gt;&lt;P&gt;Note that the AAD application should be a &lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/register-app" target="_blank"&gt;native app&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using Microsoft.IdentityModel.Clients.ActiveDirectory;&lt;BR /&gt;&lt;BR /&gt;/// &amp;lt;summary&amp;gt;
/// Returns an AccessToken for the PowerBi service.
/// &amp;lt;/summary&amp;gt;
private async Task&amp;lt;string&amp;gt; GetPowerBiAccessToken()
{
	var powerBiAccountCredentials = new UserCredential("PowerBIAADUserName", PowerBIAADUserPassword");
	var authenticationContext = new AuthenticationContext("https://login.windows.net/common/oauth2/authorize/");
	var authenticationResult = await authenticationContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", "PowerBIAADAppId", powerBiAccountCredentials);

	return authenticationResult.AccessToken;
}&lt;/PRE&gt;&lt;P&gt;This link about &lt;A href="https://docs.microsoft.com/en-us/rest/api/datacatalog/authenticate-a-client-app" target="_blank"&gt;authenticate a client app&lt;/A&gt; may be helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanos&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 09:33:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Getting-PowerBI-embed-Access-Token-via-REST/m-p/405856#M12101</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-27T09:33:14Z</dc:date>
    </item>
  </channel>
</rss>

