gpt4 book ai didi

google-api - 如何通过 Google API 获取日历资源列表

转载 作者:行者123 更新时间:2023-12-04 15:03:56 25 4
gpt4 key购买 nike

我尝试使用 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。

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

最佳答案

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

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

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

此外,我刚刚在版本 1.21 中发现了它。的 Admin-SDK Java 客户端库 (com.google.apis:google-api-services-admin-directory) Google 增加了对日历资源的支持!所以你现在需要做的就是:
Directory.resources().calendars().list("my_customer").execute();
范围是新的:https://www.googleapis.com/auth/admin.directory.resource.calendar因此需要在 Google Apps 管理控制台中对其 API 进行授权。

关于google-api - 如何通过 Google API 获取日历资源列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34364774/

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