Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Calendar API - Access own calendar via Service account
    primarykey
    data
    text
    <p>I want to access the Google Calendar API to insert entries with Python. I created a <strong>Service account</strong> on the Google API console, added an private key, downloaded it.</p> <p>But when I try to modify anyting of my calendar, it is on the same account, I get the following error message. Reading works.</p> <p>Code is</p> <pre><code>import httplib2 from oauth2client.client import SignedJwtAssertionCredentials from apiclient.discovery import build event = { 'summary' : 'Appointment', 'location' : 'Somewhere', 'start' : { 'dateTime' : '2012-09-03T10:00:00.000-07:00' }, 'end' : { 'dateTime' : '2012-09-03T10:25:00.000-07:00' } } f = file("key.p12", "rb") key = f.read() f.close() credentials = SignedJwtAssertionCredentials( service_account_name='423291807109-XXXXXXXXXXXXXXXXxx@developer.gserviceaccount.com', private_key=key, scope='https://www.googleapis.com/auth/calendar' ) http = httplib2.Http() http = credentials.authorize(http) service = build('calendar', 'v3', http=http) request = service.events().insert(calendarId='XXXXXXXXXXXXXXXXXX@group.calendar.google.com', body=event) response = request.execute() print(response) </code></pre> <p>Error message is:</p> <pre><code>apiclient.errors.HttpError: &lt;HttpError 403 when requesting https://www.googleapis.com/calendar/v3/calendars/XXXXXXXXXXXXXXXXXXX@group.calendar.google.com/events?alt=json returned "Forbidden"&gt; </code></pre> <p>I would have thought that I can access my own data with this service account, but it seems not to be.</p> <p>Google claims that</p> <blockquote> <p>After the Service Account has been created, you will also have access to the client ID associated with the private key. You will need both when coding your application. - <a href="https://developers.google.com/accounts/docs/OAuth2?hl=de#scenarios">https://developers.google.com/accounts/docs/OAuth2?hl=de#scenarios</a></p> </blockquote> <p>I googled about 2 hours, but it seems to be documented very bad. Is there a way I can insert new events via the Google Calendar API without user interaction (aka 3-legged OAuth) or is there a way to fix it?</p> <p>I just found deprecated ClientLoging. Why does Google makes it that difficult?</p> <p>Kind regards</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload