How do I get around HttpError 403 Insufficient Permission? (gmail api, python) How do I get around HttpError 403 Insufficient Permission? (gmail api, python) python python

How do I get around HttpError 403 Insufficient Permission? (gmail api, python)


Even though the accepted answer is 100% correct. I think it's worth pointing out that why that's the case.

When you authorize a gmail service client, you can specify several different scopes: All, compose, labels, etc...

These are all listed here: https://developers.google.com/gmail/api/auth/scopes

The scope mentioned in the answer provides complete gmail access.


Solved it by changing the SCOPES line to:

SCOPES = 'https://mail.google.com/'

Email sending works perfectly


Gmail API has these scopes: gmail api scopes

For sending emails, https://www.googleapis.com/auth/gmail.send is needed or full access https://mail.google.com/.

The scopes taken from here.