Good day. Already what day I fight with google api. I connected google-api-php-client, created and connected JWT (json-file) to use the service-account API access (without oauth2). But, you see, I didn’t see it somewhere, because I never got access to the calendar data.
Here is what we have:
require_once 'google-api-php-client/vendor/autoload.php'; $credentials_file = 'calendar-91713b63060f.json'; $client = new Google_Client(); $client->setApplicationName("calendar"); $client->setScopes(['https://www.googleapis.com/auth/calendar']); $client->setAuthConfig($credentials_file); $service = new Google_Service_Calendar($client); $optParams = array( 'maxResults' => 10 ); $results = $service->events->listEvents('primary', $optParams); var_dump($results); The code is even executed, but returns strange values:
object(Google_Service_Calendar_CalendarList)#67 (10) { ["collection_key":protected]=> string(5) "items" ["etag"]=> string(18) ""p32sf76fmi6css0g"" ["itemsType":protected]=> string(41) "Google_Service_Calendar_CalendarListEntry" ["itemsDataType":protected]=> string(5) "array" ["kind"]=> string(21) "calendar#calendarList" ["nextPageToken"]=> NULL ["nextSyncToken"]=> string(84) "CLjzmfaRmc4CEjRjYWxlbmRhckBtYWNyby1tZW5kZXItMTM3ODIzLmlhbS5nc2VydmljZWFjY291bnQuY29t" ["internal_gapi_mappings":protected]=> array(0) { } ["modelData":protected]=> array(1) { //В этом поле не должно быть пустого массива.. ["items"]=> array(0) { } } ["processed":protected]=> array(0) { } } If anyone came across the Google Calendar API and Service account I will be glad to hear the advice))