Home > front end >  Reading labels works but reading messages results in ACCESS_TOKEN_SCOPE_INSUFFICIENT
Reading labels works but reading messages results in ACCESS_TOKEN_SCOPE_INSUFFICIENT

Time:09-07

I have created one poc using Gmail API which read all email and print on console. I have take refrence from enter image description here

Best practice is to only request the permissions you need. So the code is asking for the GmailScopes.GMAIL_LABELS permission which will only give you access to see the lables

Now to read a users messages the enter image description here

as you can see the label scope is not there. Thats because you need a higher level of permissions to access this data..

Solution:

Change the scope in your code to request one of the scopes needed for messgaes.list.

Then you need to reauthorize your application. YOu can do this in a few was.

  1. delete the file found in TOKENS_DIRECTORY_PATH
  2. change .authorize("user"); the text passed here to something else.

When you run your app again it should prompt you for authorization again.

  • Related