<?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 Unable to generate Access Token with .NET Core in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Unable-to-generate-Access-Token-with-NET-Core/m-p/685358#M19325</link>
    <description>&lt;P&gt;I'm trying to Embed Power BI Report using .NET Core Web Application and Angular. For this I used PowerBIEmbedded_AppOwnsData( .NET MVC) sample and successfully able to generate tokens and embed the report there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in .NET Core Application as there is no&amp;nbsp;AcquireTokenAsync method so I refered this &lt;A title="Embed Power BI dashboard in ASP.Net core" href="https://community.powerbi.com/t5/Developer/Embed-Power-BI-dashboard-in-ASP-Net-core/m-p/284314#M8436" target="_blank" rel="noopener"&gt;Embed Power BI dashboard in ASP.Net core&lt;/A&gt;&amp;nbsp; which uses&amp;nbsp;Resource Owner Password Credentials Grant flow and in the below coding using the same request body as I used earlier in&amp;nbsp;PowerBIEmbedded_AppOwnsData(.NET) App.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; private async Task&amp;lt;OAuthResult&amp;gt; AuthenticateAsync()
        {
            var oauthEndpoint = new Uri("https://login.microsoftonline.com/common/oauth2/token");
            using (var client = new HttpClient())
            {
                var result = await client.PostAsync(oauthEndpoint, new FormUrlEncodedContent(new[]
                 {
                     new KeyValuePair&amp;lt;string,string&amp;gt;("resource", "https://analysis.windows.net/powerbi/api"),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("client_id", ApplicationId),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("client_secret", ApplicationSecret),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("grant_type", "password"),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("username", Username),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("password", Password),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("scope", "openid")
                 }
                ));

                var content = await result.Content.ReadAsStringAsync();
                return JsonConvert.DeserializeObject&amp;lt;OAuthResult&amp;gt;(content);
            }

        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this time I am getting an error response which was succesful in .NET Sample&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
    "error": "invalid_grant",
    "error_description": "AADSTS50126: Invalid username or password.\r\nTrace ID: e4813657-d71a-480c-87a2-1140a49b6f00\r\nCorrelation ID: ba79a622-32e2-4a12-b7fd-65a21a99f378\r\nTimestamp: 2019-05-07 09:46:05Z",
    "error_codes": [
        50126
    ],
    "timestamp": "2019-05-07 09:46:05Z",
    "trace_id": "e4813657-d71a-480c-87a2-1140a49b6f00",
    "correlation_id": "ba79a622-32e2-4a12-b7fd-65a21a99f378"
}&lt;/PRE&gt;&lt;P&gt;Please Help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;</description>
    <pubDate>Tue, 07 May 2019 10:10:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-05-07T10:10:21Z</dc:date>
    <item>
      <title>Unable to generate Access Token with .NET Core</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Unable-to-generate-Access-Token-with-NET-Core/m-p/685358#M19325</link>
      <description>&lt;P&gt;I'm trying to Embed Power BI Report using .NET Core Web Application and Angular. For this I used PowerBIEmbedded_AppOwnsData( .NET MVC) sample and successfully able to generate tokens and embed the report there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in .NET Core Application as there is no&amp;nbsp;AcquireTokenAsync method so I refered this &lt;A title="Embed Power BI dashboard in ASP.Net core" href="https://community.powerbi.com/t5/Developer/Embed-Power-BI-dashboard-in-ASP-Net-core/m-p/284314#M8436" target="_blank" rel="noopener"&gt;Embed Power BI dashboard in ASP.Net core&lt;/A&gt;&amp;nbsp; which uses&amp;nbsp;Resource Owner Password Credentials Grant flow and in the below coding using the same request body as I used earlier in&amp;nbsp;PowerBIEmbedded_AppOwnsData(.NET) App.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; private async Task&amp;lt;OAuthResult&amp;gt; AuthenticateAsync()
        {
            var oauthEndpoint = new Uri("https://login.microsoftonline.com/common/oauth2/token");
            using (var client = new HttpClient())
            {
                var result = await client.PostAsync(oauthEndpoint, new FormUrlEncodedContent(new[]
                 {
                     new KeyValuePair&amp;lt;string,string&amp;gt;("resource", "https://analysis.windows.net/powerbi/api"),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("client_id", ApplicationId),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("client_secret", ApplicationSecret),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("grant_type", "password"),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("username", Username),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("password", Password),
                     new KeyValuePair&amp;lt;string,string&amp;gt;("scope", "openid")
                 }
                ));

                var content = await result.Content.ReadAsStringAsync();
                return JsonConvert.DeserializeObject&amp;lt;OAuthResult&amp;gt;(content);
            }

        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this time I am getting an error response which was succesful in .NET Sample&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
    "error": "invalid_grant",
    "error_description": "AADSTS50126: Invalid username or password.\r\nTrace ID: e4813657-d71a-480c-87a2-1140a49b6f00\r\nCorrelation ID: ba79a622-32e2-4a12-b7fd-65a21a99f378\r\nTimestamp: 2019-05-07 09:46:05Z",
    "error_codes": [
        50126
    ],
    "timestamp": "2019-05-07 09:46:05Z",
    "trace_id": "e4813657-d71a-480c-87a2-1140a49b6f00",
    "correlation_id": "ba79a622-32e2-4a12-b7fd-65a21a99f378"
}&lt;/PRE&gt;&lt;P&gt;Please Help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;</description>
      <pubDate>Tue, 07 May 2019 10:10:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Unable-to-generate-Access-Token-with-NET-Core/m-p/685358#M19325</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-07T10:10:21Z</dc:date>
    </item>
  </channel>
</rss>

