【问题标题】:Is there a way to search users by externalid using the googleapis/google-api-python-client library?有没有办法使用 googleapis/google-api-python-client 库通过 externalid 搜索用户?
【发布时间】:2021-07-02 04:29:22
【问题描述】:

我正在编写一个 python 应用程序,它使用 Google Admin SDK 在用户目录中搜索用户。我需要通过外部 ID 或员工 ID 搜索用户,它似乎没有在 python 库中实现(https://github.com/googleapis/google-api-python-client#installation),但正如官方文档中所说,谷歌提供了支持,请参阅(@987654322 @)

如果有人能帮助指出问题,我将不胜感激。

【问题讨论】:

    标签: google-admin-sdk google-workspace google-api-python-client


    【解决方案1】:

    回答

    可以使用查询参数query通过外部ID搜索用户。

    一步一步

    1. 检查Python Quickstart
    2. 使用方法users.list
    3. 定义客户。您可以使用my_customer
    4. 定义您的query。示例:query = 'externalId:someValue'
    5. Get 匹配list 的结果的用户

    代码

    results = service.users().list( customer='my_customer',
                                    query='externalId:someValue',
                                    orderBy='email'
                                    ).execute()
    users = results.get('users', [])
    

    参考

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-15
      • 1970-01-01
      • 2016-05-09
      • 2013-12-27
      • 1970-01-01
      • 2015-01-12
      • 2019-11-21
      • 1970-01-01
      相关资源
      最近更新 更多