如何获取Google Apps帐户的CustomerId(或其他主键)? [英] How to get a CustomerId (or other primary key) for a Google Apps account?

查看:275
本文介绍了如何获取Google Apps帐户的CustomerId(或其他主键)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户登录到我们的Marketplace V2应用程序时,我们需要知道该用户属于哪个Google Apps帐户.

When a user logs on to our Marketplace V2 app, we need to know which Google Apps account the user belongs to.

id_token包含"hd"参数(域名),但这还不够,因为Google Apps帐户可以具有多个域.

The id_token contains the 'hd' parameter (the domain name), but that's not enough, as a Google Apps account can have multiple domains.

CustomerId似乎是一个很好的主键,可以将用户匹配到正确的Google Apps帐户.问题是,它似乎没有包含在id_token中.有什么方法可以弄清楚用户的CustomerId是什么.

CustomerId seems like a good primary key to match users to the correct Google Apps account. The problem is, it doesn't seem to be included in the id_token. Is there some way to figure out what the CustomerId of a user is.

将是Admin SDK的一种选择,但是在几乎所有情况下,对Admin SDK的调用都会失败,并显示域无法使用API​​".我在上一个答案中读到,当管理员安装Marketplace应用时,Google会自动(重新)启用API访问权限,但这并不是真的,因为对Admin SDK的调用几乎是行不通的.

The Admin SDK would be one option, but in almost all cases, calls to the Admin SDK fail with "Domain cannot use APIs". I read in a previous answer that Google automatically (re-)enables API access when an administrator installs a Marketplace app, but that can't be true because a call to the Admin SDK hardly ever works.

是否有人对如何获取customerId或其他主键有任何建议,或者是否有其他技巧可以使Admin SDK正常工作(而无需指示人们更改其Google Apps Scurity设置,因为这几乎可以解决问题)毫不费力的Marketplace安装)

Does anyone have any suggestions on how to get a customerId or other primary key otherwise, or another trick to get the Admin SDK working (without having to instruct people to change their Google Apps Scurity settings, because that pretty much defeats the point of an effortless Marketplace installation).

谢谢!

推荐答案

要在安装Google Apps Marketplace应用后使Admin SDK正常运行,您必须:

To make the Admin SDK work after installation of your Google apps marketplace app, you must :

  • 将管理SDK添加到您的云项目中

  • add the admin SDK to your cloud project

将Google Apps Marketplace SDK添加到您的云项目中

add the Google Apps marketplace SDK to your cloud project

进入市场应用程序的配置并添加所需的admin SDK范围

go into the configuration of the marketplace app and add the required admin SDK scope

安装后,您的服务帐户将有权在安装了市场应用程序的域上调用Admin SDK.

After installation, your service account will have permission to call the Admin SDK on the domain that installed your marketplace app.

文档说明:要检索customerId,请使用检索用户操作.

所以您至少需要这个范围:

So you will need at least this scope :

查看和管理您域中用户的配置

View and manage the provisioning of users on your domain

此外,您将需要知道域中管理员的电子邮件地址.

Additonally, you will need to know the email address of a adminstrator at the domain.

附带说明:我相信您可以使用"my_customer"代替API调用中的客户ID,至少可以用于admin SDK.

On a side note : I believe you can use "my_customer" as a replacement for the customer ID in API calls, at least for the admin SDK.

更新:

update : http://googleappsupdates.blogspot.be/2014/09/new-features-in-admin-sdk-custom-user.html Historically, only admins have been able to access the data in the Admin SDK. Beginning today, any user (not just admins) will now be able to call the Directory API to read the profile of any user on the domain (of course, we will respect ACLing settings and profile sharing settings).

这篇关于如何获取Google Apps帐户的CustomerId(或其他主键)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆