1
According to the Google APIs Explorer, the OAtuth 2.0 scope you’re using:
https://www.googleapis.com/auth/gmail.compose
… only allows:
Manage drafts and send emails
But you’re trying to use it for this:
https://www.googleapis.com/gmail/v1/users/me/messages
That is, to view email. You need the right scope:
https://mail.google.com/
… which allows:
View and manage your mail
So the error message is completely appropriate. You’ve asked for and gotten permission to do one thing, tried to do something different, and gotten a permissions error.
Source:stackexchange.com