Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerBI AADSTS90002: Tenant authorize not found

Reference: Power BI Sample Solution

I have moved the necessary code from the sample solution to my solution and its giving me the following error when authenticating:

AADSTS90002: Tenant authorize not found. This may happen if there are no active subscriptions for the tenant. Check with your subscription administrator.

I am authenticating with these 2 lines:

 var authenticationContext = new AuthenticationContext(AuthorityUrl);
 var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential);

The error is occurring on the last line. Below are values in my web.config:

<add key="authorityUrl" value="https://login.windows.net/common/oauth2/authorize/" />
<add key="resourceUrl" value="https://analysis.windows.net/powerbi/api" />

Again, this works 100% in the sample app but not when I move to my app. Any ideas why ?

Thanks in advance for any help.

like image 677
AxleWack Avatar asked Nov 27 '18 15:11

AxleWack


2 Answers

In my case instead of downgrading Microsoft.IdentityModel.Clients.ActiveDirectory, I changed the authentication endpoint from https://login.windows.net/{My tenant}/oauth2/tokento https://login.microsoftonline.com/{My tenant} which resolved the issue.

like image 77
Amir Chatrbahr Avatar answered Sep 21 '22 12:09

Amir Chatrbahr


So after some research I found that it was to do with the version of the following nuget packages:

Microsoft.IdentityModel.Clients.ActiveDirectory
Microsoft.PowerBI.Api

The following versions needed to be used:

Microsoft.IdentityModel.Clients.ActiveDirectory v3.13.9
Microsoft.PowerBI.Api V2.0.12

It seems it has something to do with the endpoints that are used. If you downgrade to the above versions(which are the same versions used in the sample tool provided), then it works.

The latest versions use something like this : https://login.microsoftonline.com/common/ where the versions provided in the same uses : https://login.windows.net/common/oauth2/authorize/

Once I "downgraded" my versions, it authenticated!

Hope this helps someone else.

like image 36
AxleWack Avatar answered Sep 17 '22 12:09

AxleWack