gpt4 book ai didi

java - 如何授予客户端应用程序访问 Microsoft Azure 中请求的范围的权限

转载 作者:行者123 更新时间:2023-12-02 23:38:56 24 4
gpt4 key购买 nike

我收到此错误

com.microsoft.aad.msal4j.MsalInteractionRequiredException:
AADSTS70000: The request was denied because one or more scopes requested are unauthorized or expired. The user must first sign in and grant the client application access to the requested scope.

Trace ID: add5eedb-86d5-41bc-bad3-129298e3ca00
Correlation ID: 1d2ab508-8ec6-49d7-abaa-d1b8feaedda8

我在任何组织目录(任何 Azure AD 目录 - Multi-Tenancy )和个人 Microsoft 帐户(例如 Skype、Xbox)azure 帐户中的帐户中注册应用程序

API 权限:

委托(delegate):

  • 日历。阅读
  • 日历.ReadWrite
  • 离线访问
  • openid
  • 个人资料
  • 用户.阅读
  • 用户.阅读.全部
  • 电子邮件
  • 邮件.阅读

应用:

  • 日历。阅读
  • 日历.ReadWrite

我在 azure 门户中提供了所需的权限和范围(公开 API),但仍然收到此错误。我尝试解决此错误超过一天,但我不明白我做错了什么?

用户登录时未询问日历的权限。

我使用了 msal4j 版本 1.6.1 依赖项

enter image description here

如何解决这个错误?

最佳答案

我通过在 AuthorizationRequestUrlParameters 中添加 Calendars.ReadWrite 范围解决了这个问题

<小时/>

在下面的字符串 updatedScopes 中,我传递了 null,因此它被视为 Microsoft 的默认范围,并且不要求日历权限。

String updatedScopes = scope == null ? "Calendars.ReadWrite" : scope;

PublicClientApplication pca = PublicClientApplication.builder(clientId).authority(authority).build();
AuthorizationRequestUrlParameters parameters = AuthorizationRequestUrlParameters
.builder(redirectURL,Collections.singleton(updatedScopes))
.responseMode(ResponseMode.QUERY)
.prompt(Prompt.SELECT_ACCOUNT).state(state).nonce(nonce)
.claimsChallenge(claims).build();

关于java - 如何授予客户端应用程序访问 Microsoft Azure 中请求的范围的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65845115/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com