排查 Directory API 问题
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页介绍了您作为经销商在使用 Directory API 时可能会遇到的一些常见问题。
400:badRequest
当向方法传递的参数值不正确时,就会出现此错误。
如果使用 users.get
方法,请验证传递给 userKey
参数的值是否为用户的主电子邮件地址、别名电子邮件地址或唯一的用户 ID。
如果使用 users.list
方法,请验证以下参数:
customer
参数:仅使用 Google 生成的 customerId
。请勿使用客户的实际网域。我们建议使用此参数,因为如果客户有辅助网域,使用 domain
参数只会返回电子邮件地址位于该特定网域中的用户。
domain
参数:仅使用客户的实际网域。请勿使用 Google 生成的
customerId
。
403:domainCannotUseApis
如果客户已停用经销商对 Admin SDK API 的访问权限,则会发生此错误。如需解决此问题,请让客户重新启用对 Admin SDK API 的访问权限。如需了解详情,请参阅控制 API 访问权限。
如果您尝试获取当前许可用户的数量,但收到此错误,请使用订阅资源中的 licensedNumberOfSeats
字段,而不是调用 users.list
方法。
403:forbidden
如果您不是客户的所有者,或者您的客户已停用转销商对其管理控制台的访问权限,就会发生此错误。
如需解决此问题,请在进行调用之前调用 customers.get
方法以验证转销商对客户的所有权,或者让客户重新启用对其管理控制台的转销商访问权限。如需了解详情,请参阅访问客户的管理控制台。
如果 Google Cloud 项目中未启用 API,则会发生此错误。如需解决此问题,请前往 Google Cloud 控制台,然后启用该 API。如需了解详情,请参阅启用 Google Workspace API。
409:duplicate
如果您尝试添加新用户,但客户的主电子邮件地址已存在于以下任一位置,则会发生此错误:
- 您尝试将这些用户添加到的当前 Google Workspace 账号。
- 其他 Google 产品(而非 Google Workspace)。
如需解决此问题,请执行以下操作:
调用 users.get
方法。
如果您收到 200
响应,则表示相应用户已存在于客户的 Google Workspace 账号中。您无法将此用户添加到相应账号。
如果您收到 403 forbidden
响应,则表示主电子邮件参数中的网域不是转售客户,或者主电子邮件之前已用于其他 Google 产品,并且必须先验证客户的网域,然后才能成功添加此用户。
如果您可以验证客户的网域,请执行以下操作:
- 使用
users.insert
方法创建临时管理员用户,然后继续完成配置,直至最终的网域验证步骤。
- 验证网域时,请将临时用户添加到
webResource.insert
调用的请求正文的 owners[]
参数中。
重复此调用,直到收到 200
响应。
- 验证网域后,使用
users.patch
或 users.update
方法重命名临时用户名。
如果您无法验证客户的网域,请执行以下操作:
- 使用
users.insert
方法创建临时管理员用户。
- 让客户以临时用户身份登录,并通过管理控制台验证其网域。
- 网域验证完毕后,客户或您可以重命名临时用户名。您可以使用
users.patch
或 users.update
方法。
412:limitExceeded
当客户达到其席位上限时,系统会显示此错误。如需解决此问题,请使用 subscriptions.changeSeats
方法,并根据用户的订阅方案使用以下方法:
- 对于
FLEXIBLE
,增加 maximumNumberOfSeats
参数。
- 对于
ANNUAL
,增加 numberOfSeats
参数。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Troubleshoot Directory API issues\n\nThis page describes some common issues that you might encounter involving the\nDirectory API as a reseller.\n\n`400:badRequest`\n----------------\n\nThis error occurs when an incorrect parameter value is passed into the method.\n\nIf using the `users.get` method, verify that the value passed into the `userKey`\nparameter is either the user's primary email address, alias email address, or\nunique user ID.\n\nIf using the `users.list` method, verify the following parameters:\n\n- `customer` parameter: Only use the `customerId` that was generated by Google. Don't use the actual customer's domain. We recommend using this parameter because if a customer has secondary domains, using the `domain` parameter only returns users with email addresses on that particular domain.\n- `domain` parameter: Only use the actual customer's domain. Don't use the \n `customerId` that was generated by Google.\n\n`403:domainCannotUseApis`\n-------------------------\n\nThis error occurs when your customer has disable reseller access to the\nAdmin SDK API. To resolve this issue, ask your customer to re-enable access to\nthe Admin SDK API. For more information, see\n[Control API access](https://support.google.com/a/answer/60757).\n\nIf you're trying to get the count of current licensed users and you get this\nerror, instead of calling the `users.list` method, use the `licensedNumberOfSeats` field\nfrom the subscription resource.\n\n`403:forbidden`\n---------------\n\nThis error occurs when you don't own the customer or your customer has disabled\nreseller access to their Admin console.\n\nTo resolve this issue, either call the\n[`customers.get` method](/workspace/admin/reseller/v1/reference/customers/get)\nbefore making calls to verify reseller ownership of customer or ask your\ncustomer to re-enable reseller access to their Admin console. For more\ninformation, see\n[Access a customer's Admin console](https://support.google.com/work/reseller/answer/6184379).\n\n`403:usageLimits.accessNotConfigured`\n-------------------------------------\n\nThis error occurs when the API isn't enabled in the Google Cloud project. To resolve\nthis issue, go to the Google Cloud console, and enable the API. For more\ninformation, see\n[Enable Google Workspace APIs](/workspace/guides/enable-apis).\n\n`409:duplicate`\n---------------\n\nThis error occurs when you're trying to add a new user, but the customer's\nprimary email already exists within one of the following:\n\n- Current Google Workspace account that you're trying to add them to.\n- Another Google product (not Google Workspace).\n\nTo resolve this issue, do the following:\n\n1. Call the `users.get` method.\n\n If you get a `200` response, then the user already exists in the customer's\n Google Workspace Account. You can't add this user to the account.\n\n If you get a `403 forbidden` response, then either the domain in the primary\n email parameter isn't a resold customer or the primary email has been used\n previously for a different Google product and the customer's domain must\n first be verified before this user can successfully be added.\n2. If you can verify the customer's domain, do the following:\n\n 1. Create a temporary admin user using the [`users.insert` method](/workspace/admin/directory/v1/reference/users/insert) and continue provisioning to the final domain verification step.\n 2. When verifying the domain, add the temporary users into the `owners[]` parameter of the request body for the [`webResource.insert` call](/site-verification/v1/webResource/insert). Make this call until you receive a `200` response.\n 3. After the domain is verified, rename the temporary username by using either the [`users.patch`](/workspace/admin/directory/v1/reference/users/patch) or the [`users.update`](/workspace/admin/directory/reference/rest/v1/users/update) methods.\n3. If you can't verify the customer's domain, do the following:\n\n 1. Create a temporary admin user using the [`users.insert` method](/workspace/admin/directory/v1/reference/users/insert).\n 2. Have your customer sign in as the temporary user and verify their domain through the Admin console.\n 3. After the domain is verified, either the customer or you can rename the temporary username. You can use either the [`users.patch`](/workspace/admin/directory/v1/reference/users/patch) or the [`users.update`](/workspace/admin/directory/reference/rest/v1/users/update) methods.\n\n`412:limitExceeded`\n-------------------\n\nThis error occurs when your customer has reached their maximum seat limit. To\nresolve this issue, Use the [`subscriptions.changeSeats` method](/workspace/admin/reseller/v1/reference/subscriptions/changeSeats)\nand depending on their subscription plan, use the following:\n\n- For `FLEXIBLE`, increase the `maximumNumberOfSeats` parameter.\n- For `ANNUAL`, increase the `numberOfSeats` parameter."]]