I am updating the label of a message. I get a 403 error as you can see below.
if (!emailInfoResponse.LabelIds.Contains(SEND4PROCESSING))
{
Console.WriteLine("PROCESS ALERT " + subject);
ModifyMessageRequest mods = new ModifyMessageRequest();
List<String> labelsToAdd = new List<String>()
{
SEND4PROCESSING
};
mods.AddLabelIds = labelsToAdd;
// mods.RemoveLabelIds = labelsToRemove;
service.Users.Messages.Modify(mods, myemail, message.Id).Execute();
}
full code @ full code here and exception @ line 134
Google.GoogleApiException
HResult=0x80131500
Message=Google.Apis.Requests.RequestError
Insufficient Permission [403]
Errors [
Message[Insufficient Permission] Location[ - ] Reason[insufficientPermissions] Domain[global]
]
Source=Google.Apis
StackTrace:
at Google.Apis.Requests.ClientServiceRequest`1.<ParseResponse>d__31.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Google.Apis.Requests.ClientServiceRequest`1.Execute()
at IBTrading.GmailQuickstart..ctor() in C:\Users \Documents\Visual Studio 2019\Projects\IBTrading\GmailQuickstart.cs:line 134
at IBTrading.Program.Main(String[] args) in C:\Users \Documents\Visual Studio 2019\Projects\IBTrading\Program.cs:line 14
i remembed to setup the update permission as you can see in the screenshot below.
Line 22 in your code is
static string[] Scopes = { GmailService.Scope.MailGoogleCom };
The documentation for Users.messages: modify
specifies:
This request requires authorization with at least one of the following scopes:
Scope
Also be aware that after you changed the scopes from
GmailService.Scope.GmailReadonly
you need to delete you previous credentials / token file.
User contributions licensed under CC BY-SA 3.0