问题
I am trying to read the gmail mail message, using gmail api, and after reading the mail, I am removing the message label, so that I don't need to process it again. I am able to read the mail successfully, but when I am trying to modify the message Label
(service.Users.Messages.Modify(mods, userId, messageId).Execute();
)
then I am getting the error message:
An error occurred: Google.Apis.Requests.RequestError
Insufficient Permission [403]
Errors [
Message[Insufficient Permission] Location[ - ] Reason[insufficientPermis
sions] Domain[global]>
].
I am not able to figure out, what may have gone wrong? Thanks in advance.
回答1:
you need to add the priviliges to the scope variable and then to delete the file storedCredentials (C:\Users\Administrateur.credentials.. )
回答2:
I had similar problems with a console application using a Service Account API key. After adding all the necessary Scopes, as mentioned by Tholle above, the application has to be updated with the necessary permissions in the Google admin console. To do this, make sure you go to Admin console and remove the current app and execute the program again to get a new token with new permissions with the updated scope.
Another way to accomplish the same is to do what Mohamed has mentioned above. That is to remove the JSON file from the "...User\[UserName]\.credetials\[apiCredentialName].json" folder. This will force the app to authenticate and get a new token. Hope this helps some one :-)
来源:https://stackoverflow.com/questions/31668506/insufficient-permission-403-error-while-modifying-the-message-label-using-gmai