0

我正在尝试编写一个 powershell 脚本,该脚本使用 Invoke-RestMethod 连接到 Google + Api 并使用已被授予域范围授权的服务帐户进行身份验证。然后我想使用列表名称来检索 google + 用户 ID,然后我想从那里创建一个圈子并将所有这些用户插入该圈子。

我遇到的主要问题是检索用户列表的用户 ID,我想一旦我有了那篇文章,我就能弄清楚其余的问题。

谢谢

4

1 回答 1

0

Google+ Domains API 的独特之处在于它允许您使用电子邮件地址代替 Google+ ID 进行 API 调用。这意味着,如果您的域中有用户列表,您可以通过在构建授权 API 客户端时指定他们的电子邮件地址,代表他们进行 API 调用。

在 Java 中,这是通过调用setServiceAcountUser你的GoogleCredential

GoogleCredential credential = new GoogleCredential.Builder()
    .setTransport(httpTransport)
    .setJsonFactory(jsonFactory)
    .setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
    .setServiceAccountScopes(SCOPE)
    .setServiceAccountUser(USER_EMAIL)
    .setServiceAccountPrivateKeyFromP12File(
        new java.io.File(SERVICE_ACCOUNT_PKCS12_FILE_PATH))
    .build();

有关其他示例和信息,请查看https://developers.google.com/+/domains/authentication/delegation

此外,如果您确实希望编译 Google+ ID 列表,则只需使用已验证用户的电子邮件地址进行 people.get API 调用,Google+ ID 将包含在 Person 响应中。( https://developers.google.com/+/domains/api/people/get )

于 2013-08-22T17:02:28.733 回答