如何模拟用户使用的服务帐户代其插入日历?

问题描述 投票:0回答:1

我试图创建日历,并使用我公司的用户服务帐户分享。 我想获得是无论是从我的网站代码(使用服务帐户),并从正规谷歌日历Web界面管理创建日历的功能。 所以我想我可以创建一个愚蠢的用户帐户(与凭证),与服务帐户模拟,然后创建和共享日历和管理都从我的WEBA页代码事件和谷歌普通用户界面。 它是正确的前进方式是什么?我缺少的东西吗? 如果我最后的猜测是对的,我怎么能实现它使用laravel和谷歌API的客户端为PHP?

谢谢您的意见

laravel-5 google-calendar-api google-api-php-client service-accounts
1个回答
0
投票

睡在它之后,我意识到没有必要模拟用户,并插入一个新的日历。要管理从officiale网络接口的服务帐户的日历,你可以简单地用所有者权益分享到“哑用户”

像这样的东西:

//create calendar
$calendar = new Google_Service_Calendar_Calendar();
$calendar->setSummary('calendarname');
$calendar->setTimeZone('Europe/Berlin');
$service = new Google_Service_Calendar();
$createdCalendar = $service->calendars->insert($calendar);

//share it with your dumb user 
$rule = new Google_Service_Calendar_AclRule();
$scope = new Google_Service_Calendar_AclRuleScope();
$scope->setType("user");
$scope->setValue('[email protected]');
$rule->setScope($scope);
$rule->setRole("owner");
$createdRule = $service->acl->insert(createdCalendar->getId(), $rule);

所以我的问题解决了的那一刻,我还在想,唯一的问题是我怎么能扮演与服务帐户凭据用户?嗯,我会去想它什么时候会真正有用

© www.soinside.com 2019 - 2024. All rights reserved.