Troubleshooting : Google Calendar Insert API error "Insufficient Permission: Request had insufficient authentication scopes"

Rahul Bhiwagade picture Rahul Bhiwagade · Apr 14, 2019 · Viewed 7.2k times · Source

For testing our application I need to insert/update google calendar events and verify edge cases like if a meeting invite is > 30 days it should not be shown to end user. I am doing this setup for a single gmail id [email protected] and trying to manipulate events to cover all the edge cases.

Following this link - https://developers.google.com/calendar/v3/reference/events/insert

1) I created a new project https://console.cloud.google.com.

2) Enabled Google Calendar API

3) Set up OAuth Client for credentials.json

4) Ran python quick start to get 10 calendar event - to verify step 3 was correct.

5) Now to insert an event added following scope on consent screen https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/calendar.events

6) Regenerate credential, so that it does have newly added scope for inserting event.

I am getting following error message - HttpError 403 when requesting https://www.googleapis.com/calendar/v3/calendars/primary/events?alt=json returned "Insufficient Permission: Request had insufficient authentication scopes."

I have also tried using email id in place of "primay" and again ending up with the same error.

Answer

user11420694 picture user11420694 · Apr 27, 2019

I had the same problem (=error message). Check out in the top of the demo software the following lines:

# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/calendar.readonly']

and modify to

# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/calendar']

then delete your token.pickle file, then rerun your script.