I can create events but when add attendees it returns this error i followed google guide and every thing is done but i can't figure out what the problem
My code
<?php
require_once(APP_LIB.'google-api/vendor/autoload.php');
$client = new Google_Client();
//The json file you got after creating the service account
putenv('GOOGLE_APPLICATION_CREDENTIALS=checkup-project-298014-b11ac6f73f7b.json');
$client->useApplicationDefaultCredentials();
$client->setApplicationName("test_calendar");
$client->setScopes(Google_Service_Calendar::CALENDAR);
$client->setAccessType('offline');
$service = new Google_Service_Calendar($client);
$event = new Google_Service_Calendar_Event(array(
'summary' => 'Test Test',
'location' => 'Test Test',
'description' => 'Hello world',
'start' => array(
'dateTime' => '2020-12-18T20:00:00+01:00',
'timeZone' => 'America/Los_Angeles',
),
'end' => array(
'dateTime' => '2020-12-18T21:20:00+01:00',
'timeZone' => 'America/Los_Angeles',
),
'attendees' => array(
array('email' => 'yasenabdelghany2222@gmail.com'),
),
));
$calendarId = 'xxxxxxxxx';
$event = $service->events->insert($calendarId, $event);
printf('Event created: %s', $event->htmlLink);
$conference = new Google_Service_Calendar_ConferenceData();
$conferenceRequest = new Google_Service_Calendar_CreateConferenceRequest();
$conferenceRequest->setRequestId('randomString123');
$conference->setCreateRequest($conferenceRequest);
$event->setConferenceData($conference);
// ['conferenceDataVersion' => 1] is required!
$event = $service->events->patch($calendarId, $event->id, $event, ['conferenceDataVersion' => 1]);
printf('<br>Conference created: %s', $event->hangoutLink);
// printf('Event created: %s\n', $createdEvent->htmlLink);
I'm using google-api-php-client
the error:
Google\Service\Exception: { "error": { "errors": [ { "domain": "calendar", "reason": "forbiddenForServiceAccounts", "message": "Service accounts cannot invite attendees without Domain-Wide Delegation of Authority." } ], "code": 403, "message": "Service accounts cannot invite attendees without Domain-Wide Delegation of Authority." } } in C:\wamp\www\bbb.portal.pfhcheckups.com\app\google-api\src\Http\REST.php on line 128