如何找到我的 Google Apps 帐户的不可变 ID?
Posted
技术标签:
【中文标题】如何找到我的 Google Apps 帐户的不可变 ID?【英文标题】:How do I find the immutable id of my Google Apps account? 【发布时间】:2016-02-03 07:16:38 【问题描述】:许多 Directory API 调用需要 customer 参数,称为“Google Apps 帐户的不可变 ID。(字符串)”。
例如GET https://www.googleapis.com/admin/directory/v1/customer/客户/domains
我不知道如何为我的 Google Apps 帐户查找/生成此信息。我是管理员。
有人能指点我正确的方向吗?
【问题讨论】:
你可以用自己的账号调用Users.get方法,在响应的最后可以找到customerId。 【参考方案1】:如果您是某个组织的一员,您可以在此处找到它的组织 ID:https://play.google.com/work/adminsettings?pli=1
它适用于与组织关联的 G Suite 帐户和 Gmail 帐户,但不适用于个人 Gmail 帐户。
【讨论】:
【参考方案2】:我发现的最简单的方法是使用 APIs Explorer at the bottom of the documentation 来实现 Directory API(Admin SDK)上的 Customers: get 方法。在表单上为 customerKey 输入“my_customer”,然后点击“授权并执行”按钮。
响应将包含 CustomerId(例如 Cxxxxxxxx)作为“id”。 entire response 看起来像这样:
"kind": "admin#directory#customer",
"id": string,
"etag": etag,
"customerDomain": string,
"alternateEmail": string,
"postalAddress":
"organizationName": string,
"countryCode": string,
,
"language": string,
"customerCreationTime": datetime
【讨论】:
【参考方案3】:我能够按如下方式找到 customerId
-
转到 admin.google.com
安全 -> 设置单点登录 (SSO)
你会看到这样的网址:
https://accounts.google.com/o/saml2/idp?idpid=Cxxxxxxxx
那个 Cxxxxxxxx 是你的 customerId
【讨论】:
这样找不到;也许他们改变了链接结构? 我仍然可以看到相同的 URL 和客户 ID,现在刚刚尝试过。【参考方案4】:有同样的问题,所以我不得不联系他们的聊天支持。
官方回答是: 没有任何 Web 界面可以查找此信息 - 正如我所期望的那样,例如在“组织管理面板”中。获取此信息的唯一方法是通过代码。
您必须编写额外的代码来请求有关任何现有用户的信息:
(Link to API Docs - 获取:https://www.googleapis.com/admin/directory/v1/users)
在响应中,您可以找到字段 customerId
,该字段对于公司所有域中的每个用户都是相同的。
这是找到您的组织customerId
的唯一方法...
对用户不友好,所以我现在将“功能请求”提交给 Google。
【讨论】:
这种方法需要客户ID,这让我很困惑。后来我发现可以使用“my_customer”代替客户 ID,而且响应中确实包含了实际的客户 ID。以上是关于如何找到我的 Google Apps 帐户的不可变 ID?的主要内容,如果未能解决你的问题,请参考以下文章
用于复制整个 Google Drive 文件结构的 Google Apps 脚本;如何避免超时?
如何在 Google Apps 脚本中使用服务帐户对 Google 表格进行身份验证
将 OpenID 委托给 Google(不是 Google Apps)
服务帐户可以调用 Google Apps Script Execution API 吗?
使用 Google Apps 帐户登录时,在 Android 上对 Google Play 游戏服务进行身份验证会导致错误