I am trying to embed a Google Calendar in an iframe using the embed code with the calendar id. I have created a service account and granted this account access to the calendar in question.
I can succesfully authenticate the service account using the google api client, and I can fetch the events from the calendar. However, I cannot figure out how to authenticate so I can show the iframe.
require_once __DIR__ . '/googleapi/vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName('Google Calendar API PHP');
$client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
$client->setAuthConfig('my-credentials.json');
$client->setAccessType('offline');
$service = new Google_Service_Calendar($client);
?>
<iframe src="https://calendar.google.com/calendar/embed?src=calendarId&ctz=Europe%2FCopenhagen" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>`
The result is simply a message telling me that I am not allowed to show the calendar in question.