1
votes

I can insert an event in a Google Calendar using the PHP library, but I want to create the event without a reminder (actually, I want to create it with a reminder that is not the default, but to keep things simple, I'll stick to just turning off the reminder).

Here is my code to turn off the reminder:

$reminders = new Google_EventReminders();
$reminders->setUseDefault(false);

$event->setReminders($reminders);

This seems to be sent successfully, and I get a successful return code, but when I look at the event in the calendar, I see that it still has the default reminder set.

I have looked everywhere for a solution - and the one thing I found was this: http://googleappsdeveloper.blogspot.co.uk/2012/01/calendar-api-v3-best-practices.html where it says: "Like the default reminders on the calendar, these are personal reminders for the user that is logged in, and will not influence the settings others might have for the same calendar or event."

That got me thinking about the Service Account that I am using to access the calendar. When I look at the events that have been inserted, they all say 'created by' [email protected] Does that mean that the notification is only relevant to the developer account, and not to the main account? To support this theory, I have been able to successfully insert an event using the Try It function in the Google API documentation - but these events do not have a 'created by' field in them.

So I researched how to get a Service Account to impersonate a user, and I am stuck. Here is what I have tried:

$client->setAssertionCredentials(new Google_AssertionCredentials(
    SERVICE_ACCOUNT_NAME,
    array('LINK TO auth/calendar', "LINK TO auth/calendar.readonly"),
    $key,
    'notasecret',
    'LINK TO oauth.net/grant_type/jwt/1.0/bearer',
    'my_email_address AT gmail.com'));

(my editting to substitute LINK TO and AT to overcome the SO restrictions) But this gives the following error:

Google_AuthException' with message 'Error refreshing the OAuth2 token, message: '{ "error" : "access_denied", "error_description" : "Requested scopes not allowed: LINK TO auth/calendar LINK TO auth/calendar.readonly"

(Leaving off the final email address parameter works fine - but inserts the event with the development account as the creator)

Does anyone know how to fix this please (either the reminders or the impersonation will do!)? Many thanks.

1
did you ever figure this out?Phillip Schmidt

1 Answers

0
votes

I decided that the 'created by' field is a limitation of Service Accounts when working with regular gmail accounts - which don't work very well. I have since switched to a Google Apps account (free for charities and education) and the 'created by' field no longer appears.