Insufficient permission [403] when changing message labels using gmail API in C #

I am trying to read a gmail email using the gmail api, and after reading the mail I remove the message label so that I donโ€™t need to process it again. I can read the mail successfully, but when I try to change the Label message ( service.Users.Messages.Modify(mods, userId, messageId).Execute(); )

then I get the error message:

An error occurred: Google.Apis.Requests.RequestError
Insufficient resolution [403]
Errors [
Message [Insufficient permission] Location [-] Reason [insufficient Permis
sions] Domain [global]>
].

I canโ€™t understand what may have gone wrong? Thanks in advance.

+6
source share
2 answers

you need to add priviliges to the scope variable and then delete the storedCredentials file (C: \ Users \ Administrateur.credentials ..)

+5
source

I had similar problems with a console application using the service account API key. After adding all the required areas mentioned above Tholle , the application should be updated with the necessary permissions in the Google Admin console. To do this, be sure to go to the administrator console and delete the current application and run the program again to get a new token with new permissions with an updated scope.

Another way to do the same is to do what Mohamed mentioned above. That is, delete the JSON file from the folder "... User \ [UserName] \. Credetials \ [apiCredentialName] .json". This will force the application to authenticate and receive a new token. Hope this helps someone :-)

+1
source

All Articles