I am following this document and seeing the following issue.
ERROR com.microsoft.aad.msal4j.PublicClientApplication - [Correlation ID: 6ed3f887-f7a7-4201-ba9c-6587d8510ef8] Execution of class com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier failed.
com.microsoft.aad.msal4j.MsalInteractionRequiredException: AADSTS65001: The user or administrator has not consented to use the application with ID 'ab8dd9d6-d79b-454d-9c40-236a74cfe698' named 'AzureTestApp01'. Send an interactive authorization request for this user and resource.
Trace ID: 0eb3ee9e-b1c1-43e8-90b3-2a1a70b71100
Correlation ID: 6ed3f887-f7a7-4201-ba9c-6587d8510ef8
Timestamp: 2020-06-19 22:32:40Z
I have followed the steps below:
I have referred multiple articles to resolve this; but none worked. Any pointers will be helpful. This is the code I am using:
PublicClientApplication pca = PublicClientApplication.builder(APP_ID).authority(AUTHORITY).build();
String scopes = "User.Read";
UserNamePasswordParameters parameters = UserNamePasswordParameters.builder(Collections.singleton(scopes),userName,password.toCharArray()).build();
IAuthenticationResult result = pca.acquireToken(parameters).get();
First, you need to be the administrator of the tenant (if you are not a tenant administrator, you cannot give the administrator permission), you can set up user roles according to here process.
Then follow this process to grant administrator consent to the app:
Based on your question, I used the ROPC flow test to get the access token.
Parse the token to see the scope of user.read
.
Finally, to obtain user information, visit https://graph.microsoft.com/v1.0/me
Api.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.