我可以通过 Google API v3 访问其他 Google 用户的日历吗

Gre*_*bes 3 php google-calendar-api google-api zend-framework2 google-client

我想构建一个应用程序,在用户未登录时代表我的用户管理 Google 日历中的约会。

该应用程序将是一个预订服务,订阅用户(我们的服务提供商)将预订他们不可用的时间,客户将看到服务提供商谷歌日历的忙/闲表示

该应用程序需要能够创建、删除和读取约会。

我已进入 Google Developer's Console 并拥有可弹出 Google 权限屏幕的工作代码,然后重定向到成功创建新约会的 Url。

我可以访问其他日历,但前提是他们当时登录了 Google 服务。

$client = new \Google_Client(); 
$client->addScope('https://www.googleapis.com/auth/calendar');
$service = new \Google_Service_Calendar($client);

$authUrl = $client->createAuthUrl();
Run Code Online (Sandbox Code Playgroud)

如果用户正在管理他们自己的日历,这可以正常工作。但是,我想代表他们管理约会。这将包括其他各方在日历中输入约会 - 即当日历未登录时。

我需要的是应用程序获得持久访问我用户日历的持久权限吗?

有谁知道这是否可能?关于我如何解决这个问题的想法将不胜感激。

Jay*_*Lee 5

OAuth 2.0 服务帐户是访问用户帐户的正确方法:

https://developers.google.com/accounts/docs/OAuth2ServiceAccount

您需要授予服务帐户客户端 ID 访问必要的日历 API 范围的权限:

https://developers.google.com/drive/web/delegation#delegate_domain-wide_authority_to_your_service_account

然后您的服务帐户可以模拟您的用户并代表他们执行日历操作:

https://developers.google.com/drive/web/delegation#instantiate_a_drive_service_object

这些文档描述了 Google Drive,但日历的过程是相同的。