0

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 Answer 1

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.

6
  • Eric, Do you have any complete sample showing this for the Calendar API Sep 27, 2015 at 15:03
  • No, but as mentioned the Drive API sample is almost identical. Sep 29, 2015 at 13:03
  • thanks Eric.I tried like that. But not working in different domain user email id Sep 30, 2015 at 12:13
  • Eric, My API CONSOLE in DOMAIN1.COM, nd end user is in DOMAIN2.COM. using [email protected] working fine, but using [email protected] not working getting error. Plz help me how to solve this Oct 3, 2015 at 8:23
  • You need to grant delegated authorization in each domain you want to use the service account. Oct 8, 2015 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.