C# Google.API.Requests.RequestError404-使用Gmail API更改域上用户的签名时出错

C# Google.API.Requests.RequestError404-使用Gmail API更改域上用户的签名时出错,c#,gmail-api,google-admin-sdk,C#,Gmail Api,Google Admin Sdk,我想以G套件管理员的身份通过Gmail.Net客户端库更新域用户的签名 我按照示例在google开发者控制台中进行设置并授予权限 以下是我所做的总结: 在谷歌API控制台中启用Gmail API 为我的项目创建了一个服务帐户 向服务帐户委派的域范围权限 添加,范围 我可以更新自己的电子邮件签名,但当我尝试更新我域中任何其他用户的签名时,我会出现以下错误: Google.Apis.Requests.RequestError Not Found [404] Errors [ Message[

我想以G套件管理员的身份通过Gmail.Net客户端库更新域用户的签名

我按照示例在google开发者控制台中进行设置并授予权限

以下是我所做的总结:

在谷歌API控制台中启用Gmail API 为我的项目创建了一个服务帐户 向服务帐户委派的域范围权限 添加,范围 我可以更新自己的电子邮件签名,但当我尝试更新我域中任何其他用户的签名时,我会出现以下错误:

Google.Apis.Requests.RequestError
Not Found [404]
Errors [
    Message[Not Found] Location[ - ] Reason[notFound] Domain[global]
]
这是我的密码:

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("admin@domain.com");
}
var service = new GmailService(new BaseClientService.Initializer()
    {
        ApplicationName = "Project",
        HttpClientInitializer = credential
    }
);
service.Users.Settings.SendAs.Patch(new SendAs { Signature = "Test signature..."}, "me",
    "user@domain.com").Execute();
有谁能告诉我我做错了什么吗?

若要使用服务帐户更改域用户的签名,您需要使用 这是通过CreateWithUser方法实现的

您需要分配给它的参数是用户的电子邮件,而不是管理员的电子邮件。因此:

credential = GoogleCredential.FromStream(stream).CreateScoped(new[]{GmailService.Scope.GmailSettingsBasic, GmailService.Scope.GmailSettingsSharing})
        .CreateWithUser( "user@domain.com");