0

The Google oauth2client library changed how credentials were managed, replacing SignedJwtAssertionCredentials with oauth2client.service_account.ServiceAccountCredentials. This was covered in https://github.com/google/oauth2client/issues/401 and I've followed the steps provided by dhermes to use a PEM file with the new code to authenticate.

Reading https://developers.google.com/identity/protocols/OAuth2ServiceAccount, it mentions the use of:

delegated_credentials = credentials.create_delegated('[email protected]')

which I've also added to my code but I don't know where to use delegated_credentials and the documentation doesn't give a sample.

The main bit of my script that creates the calendar event is thus:

created_event = service.events().insert(calendarId=CALENDAR, body=event).execute()

and it is there that I'm getting the 404 error. However, if I use Google's API tester and copy/paste the same calendar ID and the JSON that my script generates, the API works.

All I've changed in my script is the authentication code, but I'm not getting an authentication error response. The script was working prior to Google's API change and I'm using Google's Python library to interface with their API.

Any suggestions on what I need to look at to fix this?

1 Answer 1

1

The solution turned out to be related to how the service itself was being created.

In the script, "service" is created thus:

service = build("calendar", "v3", http=http)

What needed to change was how "http" was defined. I needed to (re-)introduce the delegated credentials thus:

http = httplib2.Http()
http = delegated_credentials.authorize(http)

After that, it all worked.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.