Is service account in google calendar api v3 the replacement of domain consume key and secret in two legged Oauth in v1?

六月ゝ 毕业季﹏ 提交于 2019-12-23 17:20:04

问题


I am trying to upgrade the google calendar API to v3 from v1 in a web service project. It worked very well with the api v1 currently, which is using the two legged Oauth for domain wide operations. For example, we're able to CRUD calendars and events in any person's calendars inside our domain, including having people subscribe a public account's calendars.

So far so good, but I didn't find a proper replacement solution for it in the api v3. By checking the service account, I downloaded the latest php client library and run some sample codes, and make some configurations in the Cpanel and console, and it does work in a simple way.

$client = new Google_Client();
$client->setApplicationName("Google Calendar PHP Starter Application");

# fetch the private key
$key = file_get_contents(KEY_FILE);

$client->setClientId(CLIENT_ID);

$auth = new Google_AssertionCredentials(
  SERVICE_ACCOUNT_NAME,
  array('https://www.googleapis.com/auth/calendar'),
  $key,
  'notasecret',
  'http://oauth.net/grant_type/jwt/1.0/bearer',
  'aaa@gmail.com'
);
$client->setAssertionCredentials($auth);

$service = new Google_CalendarService($client);    
$calendarList = $service->calendarList->get('aaa@gmail.com');

I am able to get aaa@gmail.com's calendar List by impersonating him, while I can't get bbb@gmail.com's list unless I impersonate bbb@gmail.com to rebuild the Google_AssertionCredentials. This is not as convenient as what it acts in api v1. With the domain consume key and secret set in v1, I have the magic power of anything. i.e. I can get anyone's calendar list by adding a parameter xoauth_requestor_id=AN_EMAIL.

I often need to deal with the request to update multiple people's calendars in one time. Does anyone know a good way to deal with it with the service account in api v3?

Any help will be appreciated.

来源:https://stackoverflow.com/questions/23469075/is-service-account-in-google-calendar-api-v3-the-replacement-of-domain-consume-k

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