I had successfully able to access data of domain users using a service account which is having domain wide delegation authority .
Now I want to access calendars of my domain users using the service account .
Questions I have is , is it possible to do this thing ? does it possible to access my domain users calendar without they have to share that calendar with me using service account .
I'm working in a Real estate project where users/agent can book slots of listings that they are gonna host this event and the same will be get added to their google calendar , they can also remove the event . - THIS IS WORKING FINE as users are logged in using there own gmail account so they can add/edit there calendar .
But now if I have a super admin right , want to edit/assign/delete these events from there calendar .
So ,is it possible ?
This is how i'm using service account
<?php
$client = new \Google_Client();
$authArray = array(
'https://www.googleapis.com/auth/admin.directory.user',
'https://www.googleapis.com/auth/admin.directory.group',
'https://www.googleapis.com/auth/admin.directory.resource.calendar'
);
$client->setApplicationName('appicationname');
$client->setScopes($authArray);
$client->setSubject('emailp@domain.com');
$client->setAuthConfig(public_path('path to json file service account .json'));
?>
Thanks
(Working in PHP/Laravel)
You may refer with these SO posts:1 and 2. The code should use service account to "impersonate" the domain users one by one, rather than trying to share calendars with service account. Also, you need to follow the steps for Delegating domain-wide authority to the service account in google domain admin console, and add the right scope (for calendar, it is https://www.googleapis.com/auth/calendar
).