如何使用Google Api 3为域中的任何用户插入Google Calendar Event? [英] How do I Insert Google Calendar Event using Google Api 3 for any user in the domain?

查看:74
本文介绍了如何使用Google Api 3为域中的任何用户插入Google Calendar Event?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Api v3(PHP库),并希望将事件添加到我们Google Apps域中的用户日历中.我已经在Google Developer控制台中创建了一个客户端ID,并在Google Apps管理控制台中的安全性"下授予了对其的访问权限.但是,仅当用户先前已授予对开发者帐户的访问权限时,该事件才会插入到用户的日历中.我不希望我们域中的每个用户都必须授予开发人员帐户对其日历的访问权限.

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.

在API v3下能否将事件无缝添加到用户的日历中?

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

推荐答案

在Google Apps管理控制台中向您的服务帐户授予域范围的委派并不能使其访问每个人的日历.相反,它允许服务帐户模拟您域内的任何给定用户,然后以该用户的身份进行请求.

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.

在PHP客户端库中,您可以通过在创建的Google_AssertionCredentials对象上设置sub字段来模拟用户.

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;

我们没有完整的示例来显示Calendar API,但是Drive API文档包括

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.

这篇关于如何使用Google Api 3为域中的任何用户插入Google Calendar Event?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆