Acquire access token from Azure AD for native app registration PowerBI using client credentials

0 votes

I am using adal4j (version 1.2.0) from a backend application to acquire an access token to be able to use the PowerBI REST APIs to embed reports (more specifically, the GenerateToken method). I have registered a native app in Azure, and provided it the necessary permissions. I can acquire an access token using a username/password combination as follows:

AuthenticationContext ac = new AuthenticationContext("https://login.windows.net/TENANT_ID/oauth2/authorize", false, es);
Future<AuthenticationResult> f = ac.acquireToken("https://analysis.windows.net/powerbi/api", CLIENT_ID, USERNAME, PASSWORD, null);

And then use the token to authenticate to the APIs successfully, and ultimately show the embedded report. However, I my case, I would like to of course use the client credentials (client ID, client secret) instead of a user account. I can acquire the token again as follows:

AuthenticationContext("https://login.windows.net/TENANT_ID/oauth2/authorize", false, es);
ClientCredential cc = new ClientCredential(CLIENT_ID, CLIENT_SECRET);
Future<AuthenticationResult> f = ac.acquireToken("https://analysis.windows.net/powerbi/api", cc,null);

The client ID is the application ID of the registered native app, and the client secret is defined by adding a key to the application. Again, I get the token, but now I am not able to use it to authenticate against the APIs anymore (HTTP 403, without any further details).

So my question is, that is this a valid scenario that should work in the first place, and/or am I just missing a piece of technical information either in Azure or using adal4j?

Edit: Below is a screenshot of the delegated app permissions.

Nov 12, 2018 in Power BI by Shubham
• 13,490 points
3,193 views

1 answer to this question.

0 votes

AFAIK , Power BI REST API only supports delegated permissions but does not support any application permissions . You will find no application permission available in azure portal . So Power BI REST API doesn't allow client credential flow without user identity . 

If you want to connect to Power BI REST API from a Service , you could use Resource Owner Passwords Credentials Grant flow.

answered Nov 12, 2018 by Upasana
• 8,620 points
Is there a way we can get access token without password, may using any other info ?
You cannot get the access token without a password, at least not yet. Some credentials required.

Related Questions In Power BI

+1 vote
1 answer

getting client-credentials access token to authorize Power BI

Try and make sure that the app ...READ MORE

answered Oct 17, 2018 in Power BI by Annie97
• 2,160 points
4,928 views
0 votes
1 answer

Is there a way to add a subtitle to a visual using PowerBI-client?

Currently, the PowerBI client does not natively ...READ MORE

answered Oct 25 in Power BI by pooja
• 2,700 points
44 views
+1 vote
1 answer

Is it possible to manage limits while using dedicated capacity power bi embedded app service?

These limits are not related to using ...READ MORE

answered Sep 24, 2018 in Power BI by Hannah
• 18,540 points
696 views
0 votes
1 answer

Switch Power BI data sources from Excel to Azure analysis services

One option that you should consider would ...READ MORE

answered Sep 28, 2018 in Power BI by Kalgi
• 52,350 points
673 views
0 votes
1 answer

Can't get client-credentials access token to authorize Power BI

With the assistance of some Microsoft folks ...READ MORE

answered Dec 18, 2020 in Power BI by Gitika
• 65,850 points
1,863 views
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,284 views
0 votes
1 answer

How to assign Power BI license to a new user

The assign license method of MS Graph API might ...READ MORE

answered Sep 25, 2018 in Power BI by Kalgi
• 52,350 points
861 views
0 votes
1 answer

Where is Power Bi being hosted?

Power BI is currently cloud hosted by ...READ MORE

answered Sep 28, 2018 in Power BI by Kalgi
• 52,350 points
1,042 views
0 votes
1 answer

Bar chart : Arranging in descending order using data from another chart

Select treemap.  Make it active.  Turn on Visual Interactions ...READ MORE

answered Feb 8, 2019 in Power BI by Upasana
• 8,620 points
819 views
0 votes
1 answer

Error:connecting to Azure SSAS server in Power-BI through Import mode

If I understand correctly, you're connecting to ...READ MORE

answered Nov 9, 2018 in Power BI by Upasana
• 8,620 points
2,654 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP