Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
cobra2020
New Member

NullReferenceExection when calling authenticationContext.AcquireTokenAsync

I am attempting an app_owns_data embedded PowerBI integration using the sample code from

https://github.com/Microsoft/PowerBI-Developer-Samples/tree/master/App%20Owns%20Data

 

I registered the application and added the applicationId to web.config.  In addition, specified the username and pwd of the master account.

 

On the Azure side, I configured the ADD permissions as shown below (see checked items in first image).

 

When authenticationContext.AcquireTokenAsync is invoked, I get the exception listed above.

 

Code:

 

// AuthorityUrl = https://login.microsoftonline.com/common/
// ResourceUrl = https://analysis.windows.net/powerbi/api
var authenticationContext = new AuthenticationContext(AuthorityUrl);
var credential = new UserPasswordCredential(Username, Password);
authenticationResult = authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential).Result;

 

Pictures below:

 

1. The AD permissions in Azure Portal

2. The NullReferenceException settings dialog

3. The top portion of the call-stack.

 

The version of Microsoft.IdentityModel.Clients.ActiveDirectory I use is the one form GitHub, v4.5.0.  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.

 

Has anyone experienced this?

 

img1.pngimg2.pngimg3.png

 

 

 

 

0 REPLIES 0

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.