【问题标题】:How can I get a list of calendar resources via Google API如何通过 Google API 获取日历资源列表
【发布时间】:2016-03-25 16:52:35
【问题描述】:

我尝试使用 Google API 从我公司的 Google Apps 中获取日历资源列表 (https://support.google.com/a/answer/60766?hl=en)。我尝试使用 OAuth 2.0 Playground 页面 (https://developers.google.com/oauthplayground) 来使用它。我做什么:
1. 我使用我公司的管理员帐户选择范围并授权 API 并使用此范围https://apps-apis.google.com/a/feeds/calendar/resource/
2. 我交换了令牌的授权码
3.我放了一个请求的网址:https://apps-apis.google.com/a/feeds/calendar/resource/2.0/my-company-domain-url/
4. 我发送请求,我得到错误:

HTTP/1.1 403 Forbidden
Alternate-protocol: 443:quic,p=1
Content-length: 207
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
Transfer-encoding: chunked
Expires: Fri, 18 Dec 2015 22:09:43 GMT
Server: GSE
-content-encoding: gzip
Cache-control: private, max-age=0
Date: Fri, 18 Dec 2015 22:09:43 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=604800; v="30,29,28,27,26,25"
Content-type: text/html; charset=UTF-8
<HTML>
<HEAD>
<TITLE>You are not authorized to access this API.</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>You are not authorized to access this API.</H1>
<H2>Error 403</H2>
</BODY>
</HTML>

我已经在 Developers Console 中启用了这个 API。

问题:我还需要做什么才能使其工作,即能够获取日历资源列表?

【问题讨论】:

    标签: google-api google-api-java-client google-admin-sdk


    【解决方案1】:

    您可能想试试这个链接,https://developers.google.com/google-apps/calendar/v3/reference/acl/list

    这应该会给你一个资源列表。

    这是概览信息的链接,https://developers.google.com/google-apps/calendar/v3/reference/acl

    希望对你有帮助。

    【讨论】:

    【解决方案2】:

    我只是错过了管理 API 访问的启用标志,如下所述:

    https://support.google.com/a/answer/60757?hl=en

    第二件事,更明显的是只有域管理员才能访问此 API。

    此外,我刚刚发现,在 Admin-SDK Java 客户端库 (com.google.apis:google-api-services-admin-directory) 的版本 1.21 中,Google 增加了对日历资源的支持!所以你现在需要做的就是:

    Directory.resources().calendars().list("my_customer").execute();

    范围是新的:https://www.googleapis.com/auth/admin.directory.resource.calendar,因此需要在 Google Apps 管理控制台中对其 API 进行授权。

    【讨论】:

    • 1.2.0版本之后资源工厂被部署了,如果没有看资源工厂升级版本解决
    猜你喜欢
    • 1970-01-01
    • 2015-03-01
    • 1970-01-01
    • 2015-01-16
    • 2020-03-29
    • 2014-03-13
    • 1970-01-01
    • 1970-01-01
    • 2019-08-04
    相关资源
    最近更新 更多