cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
visure Frequent Visitor
Frequent 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

Accepted Solutions
visure Frequent Visitor
Frequent Visitor

Re: REST API Silent Authentication (Token)

Thanks @Eric_Zhang, I already solved it,

 

Just read a little more how the authentication flow works Smiley Happy

View solution in original post

visure Frequent Visitor
Frequent Visitor

Re: REST API Silent Authentication (Token)

@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
Moderator Eric_Zhang
Moderator

Re: REST API Silent Authentication (Token)

visure Frequent Visitor
Frequent Visitor

Re: REST API Silent Authentication (Token)

Thanks @Eric_Zhang, I already solved it,

 

Just read a little more how the authentication flow works Smiley Happy

View solution in original post

Moderator Eric_Zhang
Moderator

Re: REST API Silent Authentication (Token)


@visure wrote:

Thanks @Eric_Zhang, I already solved it,

 

Just read a little more how the authentication flow works Smiley Happy


@visure

Could you share the solution?

visure Frequent Visitor
Frequent Visitor

Re: REST API Silent Authentication (Token)

@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

Janavarsha Frequent Visitor
Frequent Visitor

Re: REST API Silent Authentication (Token)

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

Valtyr Frequent Visitor
Frequent Visitor

Re: REST API Silent Authentication (Token)

Thanks, that did the trick for me. 

msplants Frequent Visitor
Frequent Visitor

Re: REST API Silent Authentication (Token)

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."

dharamgoyal Frequent Visitor
Frequent Visitor

Re: REST API Silent Authentication (Token)

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!

Highlighted
Ludia Frequent Visitor
Frequent Visitor

Re: REST API Silent Authentication (Token)

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

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 44 members 1,010 guests
Please welcome our newest community members: