【问题标题】:ms Graph api(beta) Access is deniedms Graph api(beta) 访问被拒绝
【发布时间】:2019-10-20 08:15:07
【问题描述】:

我正在尝试几种将 Microsoft Graph api(测试版)与 JAVA 结合使用的方法。 (我参考这个链接来连接api“https://docs.microsoft.com/en-us/graph/tutorials/java”) 而且我可以使用v1.0的所有功能,但是我不能使用beta版本。

例如,当我请求下面的代码时,他们成功返回了 JsonObject。

JsonObject response = graphClient
        .customRequest("/me/calendar")
        .buildRequest()
        .get();

但是当我请求下面的代码时,

JsonObject response = graphClient
        .customRequest("/me/findRoomLists")
        .buildRequest()
        .get();

他们返回以下错误

There was an unexpected error (type=Internal Server Error, status=500).
Error code: ErrorAccessDenied Error message: Access is denied. Check credentials and try again. GET https://graph.microsoft.com/beta//me/findRoomLists SdkVersion : graph-java/v1.5.0 Authorization : Bearer

我不知道是哪个问题...

我使用下面的代码来使用测试版。

    // Build a Graph client
    graphClient = GraphServiceClient.builder()
        .authenticationProvider(authProvider)
        .logger(logger)
        .buildClient();

    //version change 1.0 -> beta
    graphClient.setServiceRoot("https://graph.microsoft.com/beta/");

这是我在 Azure 中的 API 权限。

1. Calendars.ReadWrite
2. Mail.ReadWrite
3. User.ReadBasic.All
4. User.ReadWrite

应用范围

app.scopes=User.ReadWrite,Calendars.ReadWrite,Mail.ReadWrite

我应该修改哪些内容才能使用测试版? 如果是重复的问题,我很抱歉。

【问题讨论】:

    标签: java azure azure-active-directory microsoft-graph-api


    【解决方案1】:

    Microsoft Graph Java SDK 仅包含模型和请求构建器,用于使用流式 API 访问 v1.0 端点。 (如果特定 API 存在,则会有一个 java SDK sampleotherwise not

    即使您使用graphClient.setServiceRoot("https://graph.microsoft.com/beta/"),它仍然会使用/v1.0 类对所有内容进行序列化/反序列化。

    如果您想使用 v1.0 中不存在的资源/属性,则需要使用 beta 清单 generate the SDK code yourself

    有关更多详细信息,请查看此link,在 Microsoft Graph 产品团队工作的人 @Marc LaFleur 提到了它。

    【讨论】:

      【解决方案2】:

      更新:现在有 a beta SDK 可用于 beta 端点。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-03-28
        • 2014-09-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多