1
votes

I am following code to mark unread email as read in my Gmail using Google API C# Code. This is the code

but I am getting the following error:

Google.Apis.Requests.RequestError Insufficient Permission [403] Errors [Message[Insufficient Permission] Location[ - ] Reason[insufficientPermissions] Domain[global]]

How to resolve this issue for Gmail reading using Google API C#

1
"insufficientPermissions" - you need to look at the documentation to see what permissions you need to perform that action, - Tim
I have already read some documentation . But i did not get proper way to solve this issue - user9929711
could you show us your code? - Fedri Qrueger

1 Answers

0
votes

Messages.modify method allows you to make changes to the message. You need to modify the message and remove the UNREAD label. The message will then appear to be read

public static Message ModifyMessage(GmailService service, String userId,
      String messageId, List<String> labelsToAdd, List<String> labelsToRemove)
  {
      ModifyMessageRequest mods = new ModifyMessageRequest();
      mods.RemoveLabelIds = "UNREAD";

      try
      {
          return service.Users.Messages.Modify(mods, userId, messageId).Execute();
      }
      catch (Exception e)
      {
          Console.WriteLine("An error occurred: " + e.Message);
      }

      return null;
  }

Not on access

This method requires one of the following scopes of access