I am trying to removing the message label. I am able to read the mail successfully, but when I am trying to modify the message Label i have a problem
An error occurred: Google.Apis.Requests.RequestError Insufficient Permission [403] Errors Message[Insufficient Permission] Location[ - ] Reason[insufficientPermis sions] Domain[global]
i had to try to created a service from json but it have a same issue. and this is my code
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = clientId,
ClientSecret = clientSecret,
},
new[] { GmailService.Scope.MailGoogleCom, GmailService.Scope.GmailModify, GmailService.Scope.GmailCompose },//new[] { GmailService.Scope.GmailModify, GmailService.Scope.GmailCompose, GmailService.Scope.GmailReadonly },
"user",
CancellationToken.None).Result;
var service = new GmailService(new BaseClientService.Initializer
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
and then i call api to modify label UNREAD in message
ModifyMessageRequest mods = new ModifyMessageRequest();
mods.AddLabelIds = null;
mods.RemoveLabelIds = new List<string> { "UNREAD" });
service.Users.Messages.Modify(mods, userId, messageId).Execute();