Insufficient Permission [403] error while modifying the Message Label using gmail API in c#

こ雲淡風輕ζ 提交于 2019-12-22 04:17:20

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!