python - 获取 Google 群组成员

标签 python google-cloud-platform google-api google-groups

我正在尝试使用发现 API 获取 Google 网上论坛的所有成员。 所以我使用了 doc 中给出的代码但我收到以下错误:

'Error(2033): Group resource name has the correct format of `groups/{group_id}`, but it contains an invalid `{groupd_id}`

我使用 Google 网上论坛的电子邮件地址或纯文本名称作为 group_id,但错误仍然存​​在。 该组 ID 的正确语法是什么?

代码:

group_id = 'my_google_group@my_organization.com'
request = service.groups().memberships().searchTransitiveMemberships(parent=f'groups/{group_id}')

最佳答案

您可以获取 group_id您知道使用 gcloud 控制台的群组的电子邮件地址:

$ gcloud identity groups describe <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="136a7c66613e74617c66633e7d727e7653777c7e727a7d3d707c7e" rel="noreferrer noopener nofollow">[email protected]</a>

这将返回类似的内容:

createTime: '2019-01-01T00:00:00.000000Z'
displayName: YourGroupName
groupKey:
  id: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfa6b0aaadf2b8adb0aaaff2b1beb2ba9fbbb0b2beb6b1f1bcb0b2" rel="noreferrer noopener nofollow">[email protected]</a>
labels:
  cloudidentity.googleapis.com/groups.discussion_forum: ''
name: groups/8673hkdnjaod98f
parent: customers/Cjas8duwn
updateTime: '2021-01-01T00:00:00.000000Z'

与您相关的部分是:

name: groups/8673hkdnjaod98f

所以在这个例子中 group_id是:8673hkdnjaod98f

关于python - 获取 Google 群组成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70113262/

相关文章:

kubernetes - 如何将 GCP 用户与 GKE Kubernetes 用户关联起来,以进行身份​​验证和后续授权?

oauth - Google OAuth 2.0 SignIn API 请求联系人权限

api - AdSense 元数据中的 compatibleDimensions

python - 在两个数组的最终轴上按元素相乘

python - 如何使用sklearn的IncrementalPCApartial_fit

google-cloud-platform - 用于插入特定 BigQuery 数据集的 IAM 自定义角色

ssl - 在 GKE 上自动将 HTTP 重定向到 HTTPS

java - 如何让起始玩家等待轮到第二个回合制多人游戏

python - 'words' 是一个方法吗?

python - 来自结果集对象的 beautifulsoup 标题