I want to update signature of a domain user via Gmail .Net Client Library as G Suite administrator.
I followed this example to setup and give permissions in google developer console.
Here is the summary what I did:
- Enabled Gmail API in Google API Console
- Created a Service Account for my project
- Delegated domain-wide authority to the Service Account
- Added https://www.googleapis.com/auth/gmail.settings.sharing, https://www.googleapis.com/auth/gmail.settings.basic scopes
I'm able to update my own email signature but when I try to update signature of any other user on my domain I get following error:
Google.Apis.Requests.RequestError
Not Found [404]
Errors [
Message[Not Found] Location[ - ] Reason[notFound] Domain[global]
]
Here's my code:
GoogleCredential credential;
using (var stream = new FileStream("signature-gmailapi.json", FileMode.Open, FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream).CreateScoped(new[]
{GmailService.Scope.GmailSettingsBasic, GmailService.Scope.GmailSettingsSharing})
.CreateWithUser("[email protected]");
}
var service = new GmailService(new BaseClientService.Initializer()
{
ApplicationName = "Project",
HttpClientInitializer = credential
}
);
service.Users.Settings.SendAs.Patch(new SendAs { Signature = "Test signature..."}, "me",
"[email protected]").Execute();
Can you anyone please guide me what I' doing wrong?