<?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 NullReferenceExection when calling authenticationContext.AcquireTokenAsync in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/NullReferenceExection-when-calling-authenticationContext/m-p/631156#M18636</link>
    <description>&lt;P&gt;I am attempting an app_owns_data embedded PowerBI integration using the sample code from&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Microsoft/PowerBI-Developer-Samples/tree/master/App%20Owns%20Data" target="_blank" rel="noopener"&gt;https://github.com/Microsoft/PowerBI-Developer-Samples/tree/master/App%20Owns%20Data&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I registered the application and added the applicationId to web.config.&amp;nbsp; In addition, specified the username and pwd of the&amp;nbsp;master account.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the Azure side, I configured the ADD permissions as shown below (see checked items in first image).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When&amp;nbsp;authenticationContext.AcquireTokenAsync is invoked, I get the exception listed above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// AuthorityUrl =&amp;nbsp;https://login.microsoftonline.com/common/
//&amp;nbsp;ResourceUrl =&amp;nbsp;https://analysis.windows.net/powerbi/api
var authenticationContext = new AuthenticationContext(AuthorityUrl);
var credential = new UserPasswordCredential(Username, Password);
authenticationResult = authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential).Result;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pictures below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The AD permissions in Azure Portal&lt;/P&gt;&lt;P&gt;2. The NullReferenceException settings dialog&lt;/P&gt;&lt;P&gt;3. The top portion of the call-stack.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The version of Microsoft.IdentityModel.Clients.ActiveDirectory I use is the one form GitHub, v4.5.0.&amp;nbsp; In addition, Microsoft.PowerBI.Api is v2.4.0, but that is irrelevant here as I do not even got to the point of using it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Has anyone experienced this?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="img1.png" style="width: 539px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/148698i8773DDD5355F5931/image-size/large?v=v2&amp;amp;px=999" role="button" title="img1.png" alt="img1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="img2.png" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/148699i178D412B1FCCCB60/image-size/large?v=v2&amp;amp;px=999" role="button" title="img2.png" alt="img2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="img3.png" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/148701i6E7ACFC5C6134773/image-size/large?v=v2&amp;amp;px=999" role="button" title="img3.png" alt="img3.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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Feb 2019 17:47:28 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-02-25T17:47:28Z</dc:date>
    <item>
      <title>NullReferenceExection when calling authenticationContext.AcquireTokenAsync</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/NullReferenceExection-when-calling-authenticationContext/m-p/631156#M18636</link>
      <description>&lt;P&gt;I am attempting an app_owns_data embedded PowerBI integration using the sample code from&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Microsoft/PowerBI-Developer-Samples/tree/master/App%20Owns%20Data" target="_blank" rel="noopener"&gt;https://github.com/Microsoft/PowerBI-Developer-Samples/tree/master/App%20Owns%20Data&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I registered the application and added the applicationId to web.config.&amp;nbsp; In addition, specified the username and pwd of the&amp;nbsp;master account.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the Azure side, I configured the ADD permissions as shown below (see checked items in first image).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When&amp;nbsp;authenticationContext.AcquireTokenAsync is invoked, I get the exception listed above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// AuthorityUrl =&amp;nbsp;https://login.microsoftonline.com/common/
//&amp;nbsp;ResourceUrl =&amp;nbsp;https://analysis.windows.net/powerbi/api
var authenticationContext = new AuthenticationContext(AuthorityUrl);
var credential = new UserPasswordCredential(Username, Password);
authenticationResult = authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential).Result;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pictures below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The AD permissions in Azure Portal&lt;/P&gt;&lt;P&gt;2. The NullReferenceException settings dialog&lt;/P&gt;&lt;P&gt;3. The top portion of the call-stack.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The version of Microsoft.IdentityModel.Clients.ActiveDirectory I use is the one form GitHub, v4.5.0.&amp;nbsp; In addition, Microsoft.PowerBI.Api is v2.4.0, but that is irrelevant here as I do not even got to the point of using it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Has anyone experienced this?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="img1.png" style="width: 539px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/148698i8773DDD5355F5931/image-size/large?v=v2&amp;amp;px=999" role="button" title="img1.png" alt="img1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="img2.png" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/148699i178D412B1FCCCB60/image-size/large?v=v2&amp;amp;px=999" role="button" title="img2.png" alt="img2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="img3.png" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/148701i6E7ACFC5C6134773/image-size/large?v=v2&amp;amp;px=999" role="button" title="img3.png" alt="img3.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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 17:47:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/NullReferenceExection-when-calling-authenticationContext/m-p/631156#M18636</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-25T17:47:28Z</dc:date>
    </item>
  </channel>
</rss>

