【问题标题】:Can't create email aliases in bulk for Google Workspace无法为 Google Workspace 批量创建电子邮件别名
【发布时间】:2021-11-24 00:51:45
【问题描述】:

我有一个内置在 .NET 中的脚本,可以批量创建用户并创建别名。

用户是在 Google 管理控制台中创建的,但它似乎没有完成电子邮件别名信息。检查管理控制台后,备用电子邮件字段为空白

这是错误信息:

Google.Apis.Requests.RequestError 用户创建未完成。 [412] 错误 [消息[用户创建未完成。] Location[If-Match - header] Reason[conditionNotMet] Domain[global]]]

这是我的脚本:

// create new Gmail user                    
Google.Apis.Admin.Directory.directory_v1.Data.User newuserbody = new Google.Apis.Admin.Directory.directory_v1.Data.User();
UserName newusername = new UserName();
newuserbody.PrimaryEmail = userEmail;
newusername.GivenName = sFirst;
newusername.FamilyName = sLast;
newuserbody.Name = newusername;
newuserbody.Password = sPass;

Google.Apis.Admin.Directory.directory_v1.Data.User
user = service.Users.Insert(newuserbody).Execute();
user = null;
}

catch (Exception e) {
  LogMessage("CreateGoogleEmailApps", "Error", String.Format("Google user [{0}] could not be created at this time with error: {1}", sUN, e.Message));
}

try {
  // nickname attempt
  Alias newalias = new Alias();
  newalias.AliasValue = string.Format("username-{0}@{1}", sPass, ASAS_Create.Properties.Settings.Default.G_DOMAIN);
  Alias useralias = service.Users.Aliases.Insert(newalias, userEmail).Execute();
  newalias = null;
} catch (Exception e) {
  //LogMessage("CreateGoogleEmailApps", "Error", String.Format("Google user [{0}]'s alias could not be created at this time.", sUN));                    
  LogMessage("CreateGoogleAliasApps", "Error", string.Format("Google Alias Error for user [{0}] with error message[{1}].", sUN, e.Message));
}

【问题讨论】:

    标签: c# .net google-directory-api


    【解决方案1】:

    经过一些测试,我发现了发生了什么。

    该脚本向 Google 发出的请求超出了每分钟的配额,这就是为什么会创建用户而不是电子邮件别名的原因。

    https://cloud.google.com/iot/docs/how-tos/exponential-backoff 中实施指数退避后问题得到解决

    【讨论】:

      猜你喜欢
      • 2020-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-22
      • 1970-01-01
      • 2017-07-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多