cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
visure
Regular Visitor

REST API Silent Authentication (Token)

Hi guys,

 

I was following the steps in this topic:
Http://community.powerbi.com/t5/Developer/How-to-use-Power-BI-Rest-API-without-GUI-authentication-re...

 

To perform the same operations in PHP however I am having some difficulty playing in php,

- I created an an App at https://dev.powerbi.com/apps as NativeApp
- I gave all the permissions
- I got my client_id

 

Basically I'm making a request (post) on:
https://login.windows.net/common/oauth2/token

 

With the parameters:
grant_type = password
scope = openid
resource = https: //analysis.windows.net/powerbi/api
client_id = MY_CLIENT_IS
username = MY_USER_NAME
password = MY_PASSWORD

 

But I always get:
AADSTS65001: The user or administrator has not consented to use the application with ID 'CLIENT_ID'. Send an interactive authorization request for this user and resource. Trace ID: f9380076-1990-4d5d-b615-925a47121100

 

What's wrong?

 

Note: I don't use Azure Management Portal

2 ACCEPTED SOLUTIONS

Thanks @Eric_Zhang, I already solved it,

 

Just read a little more how the authentication flow works 🙂

View solution in original post

@Eric_Zhang

 

Of course,

 

When I calmly read the message "The user or administrator has not consented to use the application" I started to ask myself "where could I consent the permissions", the quick response came "Azure AD".

 

I started to search how the Azure AD permissions system works and I found this link:
Https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applica...

 

After reading it I conclude: I created the application through PowerBI (http://dev.powerbi.com/apps) which generated an application in Azure AD (http://portal.azure.com), so I still had to delegate the application permissions - my user was also the account administrator so I just needed to grant the permissions.

 

Steps: 

Create app on PowerBI > Go to Azure Portal > Find Azure Active Directory > Find the Application > Grant Permissions

 

Any questions are welcome.

View solution in original post

15 REPLIES 15
ZappySys
Helper I
Helper I

Please look at below blog post see it helps. 

 

https://zappysys.com/blog/howto-import-json-rest-api-power-bi/

 

Using ZappySys ODBC API drivers you can import any REST API.  

 

Check below example how to use OAuth connection in ZappySys ODBC driver. You can select Custom Provider + OAuth 2.0 Version. Select Scope, Grant Type (i.e. Password Grant), Client ID, Userid, password.

 

You can also supply non-standard OAuth attributes on Advanced Tab (e.g. resource=http://your-resource-url)

 

 

ZappySys Driver - OAuth Configuration (Grant Type, Scope, Auth URL)ZappySys Driver - OAuth Configuration (Grant Type, Scope, Auth URL)

 

ZappySys ODBC JSON Driver - Configure REST API callZappySys ODBC JSON Driver - Configure REST API callZappySys ODBC JSON Driver - SQL Query Preview (Read from JSON / XML / CSV File or REST APIZappySys ODBC JSON Driver - SQL Query Preview (Read from JSON / XML / CSV File or REST API

@ZappySys I do not think it's the case of promoting a product on an important integration issue.

msplants
Frequent Visitor

I was getting this same error in a native application using ADAL trying to access the PowerBI REST API. I had given all of the correct permissions in AAD as discussed in previous solutions, but had already received a token from a previous signin (before I gave the PowerBI Service permissions in AAD). My issue was that the previous token was stale and did not contain the updated claims. For me, the solution was to use PromptBehavior.RefreshSession as per the code below.

 

AuthenticationResult result = await authenticationContext.AcquireTokenAsync(resourceId, clientId, redirectURI, new PlatformParameters(PromptBehavior.RefreshSession, false));

 

As per MSDN, PromptBehavior.RefreshSession "Re-authorizes (through displaying webview) the resource usage, making sure that the resulting access token contains updated claims. If user logon cookies are available, the user will not be asked for credentials again and the logon dialog will dismiss automatically."

Janavarsha
Frequent Visitor

I want power bi authenication code in java.can please give some codes.

Eric_Zhang
Microsoft
Microsoft

Thanks @Eric_Zhang, I already solved it,

 

Just read a little more how the authentication flow works 🙂

View solution in original post


@visure wrote:

Thanks @Eric_Zhang, I already solved it,

 

Just read a little more how the authentication flow works 🙂


@visure

Could you share the solution?

@Eric_Zhang

 

Of course,

 

When I calmly read the message "The user or administrator has not consented to use the application" I started to ask myself "where could I consent the permissions", the quick response came "Azure AD".

 

I started to search how the Azure AD permissions system works and I found this link:
Https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applica...

 

After reading it I conclude: I created the application through PowerBI (http://dev.powerbi.com/apps) which generated an application in Azure AD (http://portal.azure.com), so I still had to delegate the application permissions - my user was also the account administrator so I just needed to grant the permissions.

 

Steps: 

Create app on PowerBI > Go to Azure Portal > Find Azure Active Directory > Find the Application > Grant Permissions

 

Any questions are welcome.

View solution in original post

Your clear and concise instructions really helped me out. I would have never figured out I had to go into portal.azure.com to enable the PowerBI permissions. I was thinking that Power BI was completely separate. Thanks a bunch for taking the time to post your solution!

Ludia
Frequent Visitor

Hello Visure,

 

Steps: 

Create app on PowerBI > Go to Azure Portal > Find Azure Active Directory > Find the Application > Grant Permissions

 

Thanks a lot for your sharing and based on your steps, i couldn't find the Application before granting permissions? Could you kindly show the steps for "Create app on Power BI"?

 

Many thanks

Ludia

visure
Regular Visitor

 Hey Ludia,

 

Just go to: https://dev.powerbi.com/apps and create your application

Hope this helps

Ludia
Frequent Visitor

@visure

Thanks a lot for your great help, my problem was solved

visure
Regular Visitor

@Ludia 

You are welcome

Hi @visure,

 

Doing same but still getting error:

AADSTS65001: The user or administrator has not consented to use the application with ID 'xxxxxxxxxxxxxxxxxx' named 'LSNTestAPP'. Send an interactive authorization request for this user and resource.\r\nTrace ID: 19f4be86-94db-45ad-961a-46a570ad4300\r\nCorrelation ID: 99c5058f-177a-459b-9509-def5865d5fcf\r\nTimestamp: 2017-12-22 06:43:15Z

 

It's error coming while login with power bi user credentials but when use azure port admin credentials then it's work so please let me know what i am missing to authenticate powerbi user to get access token.

 

I have spend lot of time on it please help me out to resove this isssue.

I hope for your quick response!

Thanks, that did the trick for me. 

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Kudoed Authors