对于Google Workspace,我正在尝试将所有用户的A列表放在一起。我域中的其他联系人

发布于 2025-01-28 14:36:06 字数 202 浏览 3 评论 0原文

我想为我域中的所有用户获取“其他联系人”列表。目前,我可以在以下内容中获取用户的“其他联系人”列表:

results = service.otherContacts().list(
        readMask="names,emailAddresses").execute()

但是是否有一种方法可以获取其他用户的列表?

I want to get the "Other Contacts" List for all users in my domain. I can currently get my user's "Other Contacts" list with the following:

results = service.otherContacts().list(
        readMask="names,emailAddresses").execute()

But is there a way to get other users' lists as well?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

燕归巢 2025-02-04 14:36:06

如果您已经可以使用该代码获得“其他联系人”,那么您需要实现的只是用户模仿在您的代码中,类似于:

from googleapiclient.discovery import build
from google.oauth2 import credentials, service_account
 
SCOPES = [Your Scopes list]

# Service Account Credentials to be used. How to create at https://developers.google.com/workspace/guides/create-credentials#service-account
SERVICE_ACCOUNT_FILE = 'yourServiceAccountCredentials.json'

credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes= SCOPES)
delegated_creds = credentials.with_subject('[email protected]')

由于创建服务帐户并生成JSON文件密钥,您需要配置域名范围范围的委派使用服务帐户的客户端ID以及您将使用的范围。

If you already can get your 'Other contacts' with that code, all you need to implement is user impersonation in your code, something like:

from googleapiclient.discovery import build
from google.oauth2 import credentials, service_account
 
SCOPES = [Your Scopes list]

# Service Account Credentials to be used. How to create at https://developers.google.com/workspace/guides/create-credentials#service-account
SERVICE_ACCOUNT_FILE = 'yourServiceAccountCredentials.json'

credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes= SCOPES)
delegated_creds = credentials.with_subject('[email protected]')

And since you are using Google Workspace after you create your Service Account and generate the JSON file key you will need to configure Domain Wide Delegation using the client ID of your Service Account plus the scopes you will use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文