我正在关注this document并看到以下问题。
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
我已按照以下步骤操作:
- 将应用注册为公共(public)客户端
- 更新了 list 以将allowPublicClient属性设置为true
- 设置用户读取权限
- 还获得了授予/撤销管理员同意
我引用了多篇文章来解决这个问题;但没有一个起作用。任何指示都会有所帮助。这是我正在使用的代码:
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();
最佳答案
首先,您需要是租户的管理员(如果您不是租户管理员,则无法授予管理员权限),可以按照 here 设置用户角色流程。
然后按照以下流程向应用程序授予管理员同意:
- 登录https://portal.azure.com作为租户管理员。
- 在以下位置打开您的应用程序注册。
- 转到“设置”,然后选择所需的权限。
- 按下授予权限按钮。
根据你的问题,我使用了 ROPC flow 测试以获取访问 token 。
关于java - AADSTS65001 : The user or administrator has not consented to use the application with ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62494916/