How do I Insert Google Calendar Event using Google Api 3 for any user in the domain?

痴心易碎 提交于 2020-01-17 03:56:10

问题


I am using Google Api v3 (PHP Libraries) and wish to add an event to a user's calendar in our Google Apps domain. I have created a client ID in the Google Developer console and have granted access to it under Security in our Google Apps Admin Console. However, the event will only insert into a user's calendar if the User has previously granted access to the developer account. I do not wish every user in our domain to have to grant the developer account access to their calendar.

Is it possible under API v3 to be able to seamlessly add an event to a user's calendar?


回答1:


Granting domain-wide delegation to your service account in the Google Apps Admin Console doesn't give it access to everyone's calendar. Instead it allows the service account to impersonate any given user within your domain, and then make requests as that user.

In the PHP client library you can impersonate a user by setting the sub field on the Google_AssertionCredentials object you created.

$auth->sub = $userEmail;

We don't have a complete sample showing this for the Calendar API, but the Drive API documentation includes a sample, and the process is identical.



来源:https://stackoverflow.com/questions/27247644/how-do-i-insert-google-calendar-event-using-google-api-3-for-any-user-in-the-dom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!