Forum Discussion
REST API Silent Authentication (Token)
- 9 years ago
Thanks Eric_Zhang, I already solved it,
Just read a little more how the authentication flow works :)
- 9 years ago
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-applicationsAfter 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.
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."