首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用应用程序ID从Java应用程序调用Microsoft Graph时出现禁止错误

使用应用程序ID从Java应用程序调用Microsoft Graph时出现禁止错误
EN

Stack Overflow用户
提问于 2021-10-29 16:46:26
回答 1查看 124关注 0票数 0

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);

代码语言:javascript
复制
    GraphServiceClient graphClient = GraphServiceClient
            .builder()
            .authenticationProvider(authProvider)
            .buildClient();

    graphClient.users().buildRequest().get();

使用

编译组:'com.microsoft.azure',名称:'azure-spring-boot',版本:'2.3.5‘

代码语言:javascript
复制
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和客户端密码,而不是创建质询。

更新:我得到的错误消息是

代码语言:javascript
复制
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 : Forbidden

Here's a link of the permissions the app has in API Permissions

我还拥有以下Azure权限管理服务的权限,以防它帮助Application.Read.All、Content.DelegatedReader、Content.SuperUser

EN

回答 1

Stack Overflow用户

发布于 2021-11-01 12:34:01

根据您授予的权限,您错过了User.ReadWriteUser.ReadWrite.All请添加该权限。

有关更多详细信息,请参阅此document

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69772322

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档