<?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: authentication issue when embedding in aspnetcore in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/385300#M11441</link>
    <description>Thank you! Was the endpoint &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Wed, 28 Mar 2018 07:06:39 GMT</pubDate>
    <dc:creator>Ameb</dc:creator>
    <dc:date>2018-03-28T07:06:39Z</dc:date>
    <item>
      <title>authentication issue when embedding in aspnetcore</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/380358#M11298</link>
      <description>&lt;P&gt;building on this previous post:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Developer/Embed-Power-BI-dashboard-in-ASP-Net-core/td-p/273279" target="_blank"&gt;https://community.powerbi.com/t5/Developer/Embed-Power-BI-dashboard-in-ASP-Net-core/td-p/273279&lt;/A&gt;&lt;/P&gt;&lt;P&gt;(&lt;SPAN&gt;Embed Power BI dashboard in ASP.Net core)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;on this line:&lt;/P&gt;&lt;PRE&gt;                string content = await result.Content.ReadAsStringAsync();&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;the content im receiving back in&amp;nbsp;AuthenticateAsync is this (only a portion):&lt;/P&gt;&lt;P&gt;"\r\n\r\n&amp;lt;!DOCTYPE html&amp;gt;\r\n&amp;lt;html dir=\"ltr\" class=\"\" lang=\"en\"&amp;gt;\r\n&amp;lt;head&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;lt;title&amp;gt;Sign in to your account&amp;lt;/title&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;lt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes\"&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;lt;meta http-equiv=\"Pragma\" content=\"no-cache\"&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;lt;meta http-equiv=\"Expires\" content=\"-1\"&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;lt;meta name=\"PageID\" content=\"ConvergedSignIn\" /&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;lt;meta name=\"SiteID\" content=\"\" /&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;lt;meta name=\"ReqLC\" content=\"1033\" /&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;lt;meta name=\"LocLC\" content=\"en-US\" /&amp;gt;\r\n\r\n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;noscript&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;meta http-equiv=\"Refresh\" content=\"0; URL=&lt;A href="https://login.windows.net/common/jsdisabled\" target="_blank"&gt;https://login.windows.net/common/jsdisabled\&lt;/A&gt;" /&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/noscript&amp;gt;\r\n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;link rel=\"shortcut icon\" href=\"&lt;A href="https://secure.aadcdn.microsoftonline-p.com/ests/2.1.7382.8/content/images/favicon_a.ico\" target="_blank"&gt;https://secure.aadcdn.microsoftonline-p.com/ests/2.1.7382.8/content/images/favicon_a.ico\&lt;/A&gt;" /&amp;gt;\r\n&amp;nbsp; &amp;nbsp; \r\n&amp;nbsp; &amp;nbsp; "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which needless to say is not JSON and certainly isnt a token!&lt;/P&gt;&lt;P&gt;can anyone tell me whats going on here? and what is my next step to getting a tooken?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the rendered outut returned from the function:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mslogin.png" style="width: 460px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/87931i70298D912D5E26F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="mslogin.png" alt="mslogin.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ps - i know my credentials work&amp;nbsp;&lt;/P&gt;&lt;P&gt;because i built the example in the standard .net version (ie minus the mods for aspnetcore)&lt;/P&gt;&lt;P&gt;and they totally worked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Mar 2018 02:28:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/380358#M11298</guid>
      <dc:creator>toy</dc:creator>
      <dc:date>2018-03-25T02:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: authentication issue when embedding in aspnetcore</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/383160#M11372</link>
      <description>&lt;P&gt;Follow the steps mentioned in the thread below:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/45480532/embed-power-bi-report-in-asp-net-core-website?utm_medium=organic&amp;amp;utm_source=google_rich_qa&amp;amp;utm_campaign=google_rich_qa" target="_self"&gt;Embed Power BI Report in Asp.Net Core Website&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The workaround here is to compose the HTTP request directly.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Not sure how the code in your tests works,t&lt;/SPAN&gt;he content you received should be the authentication page from "login.windows.net", which is used to finish the authentication and generate the token.&lt;/P&gt;&lt;P&gt;The workable content should be the content returned from "&lt;SPAN&gt;login.windows.net&lt;/SPAN&gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Mar 2018 01:55:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/383160#M11372</guid>
      <dc:creator>v-micsh-msft</dc:creator>
      <dc:date>2018-03-25T01:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: authentication issue when embedding in aspnetcore</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/383165#M11374</link>
      <description>&lt;P&gt;hey michael&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx for the response&lt;/P&gt;&lt;P&gt;but if you read my orig post&lt;/P&gt;&lt;P&gt;i stated i had already followed that post&lt;/P&gt;&lt;P&gt;and the result im getting is the result i posted&lt;/P&gt;&lt;P&gt;(adjusted so as to render the non-json result i am getting)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for clarity here is my current code:&lt;/P&gt;&lt;PRE&gt;       public async Task&amp;lt;ActionResult&amp;gt; index() {
            var result = new EmbedConfig { Username = Username };
            var error = GetWebConfigErrors();
            if (error != null)
            {
                result.ErrorMessage = error;
                return View(result);
            }

            var authenticationResult = await AuthenticateAsync();
            if (authenticationResult == null) {
                result.ErrorMessage = "Authentication Failed.";
                return View(result);
            }
            else
            {
                return View(new connectVM(
                                isJson(authenticationResult) ? JsonConvert.DeserializeObject&amp;lt;string&amp;gt;(authenticationResult) : authenticationResult));
            }

            //var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
        }


        //.private static async Task&amp;lt;OAuthResult&amp;gt; AuthenticateAsync()
        // JsonConvert.DeserializeObject&amp;lt;OAuthResult&amp;gt;(authenticationResult) 
        private static async Task&amp;lt;string&amp;gt; AuthenticateAsync()
        {
            Uri oauthEndpoint = new Uri(AuthorityUrl);
            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage result = await client.PostAsync(oauthEndpoint, new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair&amp;lt;string, string&amp;gt;("resource", ResourceUrl),
                    new KeyValuePair&amp;lt;string, string&amp;gt;("client_id", ClientId),
                    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"),
                }));

                string content = await result.Content.ReadAsStringAsync();
                //Console.WriteLine(content.ToString());
                return content.ToString();
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UPDATE:&lt;/P&gt;&lt;P&gt;ive tried logging in directly through browser url&lt;/P&gt;&lt;P&gt;here is the url im using:&lt;/P&gt;&lt;P&gt;&lt;A href="https://login.windows.net/common/oauth2/authorize/?client_id=myclientid&amp;amp;grant_type=password&amp;amp;username=myusername&amp;amp;password=mypassword&amp;amp;scope=openid" target="_blank"&gt;https://login.windows.net/common/oauth2/authorize/?client_id=myid&amp;amp;grant_type=password&amp;amp;username=myun&amp;amp;password=mypw&amp;amp;scope=openid&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;does the url at least look correct for the non-sensitive info?&lt;/P&gt;&lt;P&gt;still getting the sign in box&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 01:58:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/383165#M11374</guid>
      <dc:creator>toy</dc:creator>
      <dc:date>2018-03-27T01:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: authentication issue when embedding in aspnetcore</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/384622#M11421</link>
      <description>&lt;P&gt;I'm having the exactly same issue, with the same code. Have also tried to get the token using Postman.&lt;/P&gt;&lt;P&gt;Always getting the Sign in page as response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the request:&lt;/P&gt;&lt;PRE&gt;POST /common/oauth2/authorize/ HTTP/1.1
Host: login.windows.net
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

client_id=clientId&amp;amp;
resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi&amp;amp;
grant_type=password&amp;amp;
username=user@domain&amp;amp;
password=userpassword&amp;amp;
scope=openid&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 11:34:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/384622#M11421</guid>
      <dc:creator>Ameb</dc:creator>
      <dc:date>2018-03-27T11:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: authentication issue when embedding in aspnetcore</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/384954#M11435</link>
      <description>&lt;P&gt;endpoints have changed:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;AuthorityUrl = "&lt;/SPAN&gt;&lt;A href="https://login.windows.net/common/oauth2/token/" rel="nofollow noreferrer" target="_blank"&gt;https://login.windows.net/common/oauth2/token/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in one of the examples it was&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;AuthorityUrl = "&lt;/SPAN&gt;&lt;A href="https://login.windows.net/common/oauth2/token/" rel="nofollow noreferrer" target="_blank"&gt;https://login.windows.net/common/oauth2/&lt;/A&gt;authorize/&lt;/P&gt;&lt;P&gt;which is what i had in my code&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 18:13:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/384954#M11435</guid>
      <dc:creator>toy</dc:creator>
      <dc:date>2018-03-27T18:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: authentication issue when embedding in aspnetcore</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/385300#M11441</link>
      <description>Thank you! Was the endpoint &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 28 Mar 2018 07:06:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/authentication-issue-when-embedding-in-aspnetcore/m-p/385300#M11441</guid>
      <dc:creator>Ameb</dc:creator>
      <dc:date>2018-03-28T07:06:39Z</dc:date>
    </item>
  </channel>
</rss>

