List SCOPES = Arrays.asList("https://graph.microsoft.com/.default");final ClientSecretCredential credential = new ClientSecretCredentialBuilder() .clientId(applicationId) .clientSecret(secret) .tenantId(tenantId) .build();final TokenCredentialAuthProvider authProvider_new = new TokenCredentialAuthProvider(SCOPES,credential);
GraphServiceClient graphClient = GraphServiceClient
.builder()
.authenticationProvider(authProvider)
.buildClient();
graphClient.users().buildRequest().get();使用
编译组:'com.microsoft.azure',名称:'azure-spring-boot',版本:'2.3.5‘
compile group: 'com.google.guava', name: 'guava', version: '28.2-jre'
compile group: 'com.azure', name: 'azure-identity', version: '1.2.5'
compile group: 'com.microsoft.graph', name: 'microsoft-graph', version: '3.5.0'我已经向应用程序添加了所有必要的权限,并且已在Active Directory中获得同意,但响应相同。
在我使用用户帐户登录后,它使用以下代码工作: final DeviceCodeCredential credential1 = new DeviceCodeCredentialBuilder() .clientId(applicationId) .challengeConsumer(challenge -> System.out.println(challenge.getMessage() .build();
但我想使用ClientSecretCredential和客户端密码,而不是创建质询。
更新:我得到的错误消息是
SEVERE: Throwable detail: com.microsoft.graph.http.GraphServiceException: Error code: Authorization_RequestDenied
Error message: Insufficient privileges to complete the operation.
GET https://graph.microsoft.com/v1.0/users
SdkVersion : graph-java/v3.5.0
403 : ForbiddenHere's a link of the permissions the app has in API Permissions
我还拥有以下Azure权限管理服务的权限,以防它帮助Application.Read.All、Content.DelegatedReader、Content.SuperUser
发布于 2021-11-01 12:34:01
根据您授予的权限,您错过了User.ReadWrite和User.ReadWrite.All请添加该权限。
有关更多详细信息,请参阅此document
https://stackoverflow.com/questions/69772322
复制相似问题