【问题标题】:OAuth MSAL4J Office365 -> AccessToken error "The token contains no permissions, or permissions can not be understood."OAuth MSAL4J Office365 -> AccessToken 错误“令牌不包含权限,或无法理解权限。”
【发布时间】:2020-06-19 01:10:52
【问题描述】:

我目前正在尝试使用 MSAL4J 库来获取 ConfidentialClientApplication 的 AccessToken。我已经获得了令牌,但是当我将它传递给 Exchange 时,我收到错误“令牌不包含权限,或者权限无法被理解”。我用 jwt.io 检查了令牌,我可以看到没有“scp”字段,这意味着可能没有范围,但我不知道为什么。

访问令牌的Java代码:

String AUTHORITY = "https://login.microsoftonline.com/common";
IClientSecret createFromSecret = ClientCredentialFactory.createFromSecret(clientSecret);

Builder builder = ConfidentialClientApplication.builder(clientId, createFromSecret).authority(aUTHORITY).validateAuthority(true);
ConfidentialClientApplication application = builder.build();
HashSet<String> scopes = new HashSet<String>();
scopes.add("https://outlook.office.com/.default");
ClientCredentialParameters clientCredentialParameters = ClientCredentialParameters.builder(scopes).build();
CompletableFuture<IAuthenticationResult> acquireTokenFuture = application.acquireToken(clientCredentialParameters);
IAuthenticationResult iAuthenticationResult = acquireTokenFuture.get(30, TimeUnit.SECONDS);

iAuthenticationResult = acquireTokenFuture.get(30, TimeUnit.SECONDS);

我已经添加了必要的 api 权限并使用管理员帐户批准了它们:

有什么想法吗?

【问题讨论】:

    标签: java oauth-2.0 exchangewebservices access-token msal


    【解决方案1】:

    好像我自己找到了答案。在我的情况下,我必须添加交换权限,微软图(因为它在我发现的每个示例中都使用)在这种情况下不起作用或不够用。

    【讨论】:

      猜你喜欢
      • 2019-06-11
      • 2016-09-29
      • 1970-01-01
      • 1970-01-01
      • 2014-03-18
      • 2016-10-09
      • 1970-01-01
      • 2013-02-17
      • 2016-08-11
      相关资源
      最近更新 更多