问题描述
我想建立一个应用程序,在用户未登录时代表我的用户管理Google日历中的约会。
该应用程序将是预订服务订阅用户(我们的服务提供商)会预订他们不可用的时间,并且客户会看到服务提供商的Google日历的空闲/忙碌表示。
应用程序需要能够创建,删除和阅读约会。
我已前往Google开发者控制台,并有工作代码弹出Google Permissions屏幕,然后重定向至成功创建新约会的Url。
我可以访问其他日历,但前提是他们当时已登录Google服务。
$ client = new \Google_Client();
$ client-> addScope('https://www.googleapis.com/auth/calendar');
$ service = new \Google_Service_Calendar($ client);
$ authUrl = $ client-> createAuthUrl();
如果用户正在管理自己的日历,这可以正常工作。但是,我想代表他们管理约会。这将包括其他人进入日历进入约会 - 即当日历没有登录。
我需要的是一个持久的应用程序的权威,以获得持久的访问我的用户的日历?
有谁知道这是否可能?不胜感激我想如何解决这个问题。
OAuth 2.0服务帐户是访问用户帐户的正确方法:
您需要授予服务帐户客户端ID访问必要的日历API范围:
然后你的服务帐户可以冒充你的用户并代表他们执行日历操作:
这些文档介绍Google云端硬盘,但日历的过程完全相同。
I would like to build an application that manages appointments in Google calendar on behalf of my users when they are not logged in.
The application would be a booking service, subscribing users (our service providers) would book out the times they are not available, and customers would see a free/busy representation of the service provider's google calendar
The application would need the ability to create, delete, and read appointments.
I have gone to the Google Developer's Console and have working code that pops up the Google Permissions screen, then redirects to a Url that successfully creates a new appointment.
I can access other calendar's but only if they are are logged into Google services at that time.
$client = new \Google_Client();
$client->addScope('https://www.googleapis.com/auth/calendar');
$service = new \Google_Service_Calendar($client);
$authUrl = $client->createAuthUrl();
This works okay if the user is managing their own Calendar. However, I want to manage appointments on their behalf. This would include others parties entering appointments into the calendar - i.e. when the calendar is not logged in.
What I need is an enduring authority for application to gain enduring access to my user's calendar?
Does anyone know if this possible? Thoughts as to how I could approach the problem would be appreciated.
OAuth 2.0 service accounts are the proper method for accessing user accounts:
https://developers.google.com/accounts/docs/OAuth2ServiceAccount
You need to grant the service account client id access to the necessary Calendar API scopes:
Then your service account can impersonate your users and perform calendar operations on their behalf:
https://developers.google.com/drive/web/delegation#instantiate_a_drive_service_object
These docs describe Google Drive but the process for Calendar is identical.
这篇关于我可以通过Google API v3访问其他Google用户的日历吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!