Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 711
Rahul Bhiwagade Avatar asked Apr 14 '19 16:04

Rahul Bhiwagade


2 Answers

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.

like image 68
user11420694 Avatar answered Sep 22 '22 05:09

user11420694


If your all credentials is done perfectly. you can just simplly edit a line Go to your index.php or your filename where you generated get client and overrice the line below

$client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);

To

$client->setScopes(Google_Service_Calendar::CALENDAR);

and also make sure you have permission to create events.

Hope it will helped.

like image 20
Arman H Avatar answered Sep 21 '22 05:09

Arman H