Google People API:读取“其他联系人”有地址
我需要读取“其他联系人”的地址。 文档说为了做到这一点,应该设置READ_SOURCE_TYPE_PROFILE
。但是,当这样做时:
service = googleapiclient.discovery.build('people', 'v1', credentials=credentials)
resource = service.otherContacts()
request = resource.list(
readMask='names,emailAddresses,phoneNumbers,addresses',
sources='READ_SOURCE_TYPE_PROFILE',
pageSize=1000
)
request.execute()
...我收到以下错误:必须请求 READ_SOURCE_TYPE_CONTACT
。完整回溯:
Traceback (most recent call last):
File "C:\Users\Leo\workspace\gapitest\main.py", line 22, in <module>
response = request.execute()
File "C:\Users\Leo\workspace\gapitest\venv\lib\site-packages\googleapiclient\_helpers.py", line 131, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\Leo\workspace\gapitest\venv\lib\site-packages\googleapiclient\http.py", line 937, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://people.googleapis.com/v1/otherContacts?readMask=names%2CemailAddresses%2CphoneNumbers&sources=READ_SOURCE_TYPE_PROFILE&pageSize=1000&alt=json returned "Must request READ_SOURCE_TYPE_CONTACT". Details: "Must request READ_SOURCE_TYPE_CONTACT">
我做错了什么?
I need to read addresses of "other contacts". Docs say that in order to do this, READ_SOURCE_TYPE_PROFILE
should be set. However, when doing it like this:
service = googleapiclient.discovery.build('people', 'v1', credentials=credentials)
resource = service.otherContacts()
request = resource.list(
readMask='names,emailAddresses,phoneNumbers,addresses',
sources='READ_SOURCE_TYPE_PROFILE',
pageSize=1000
)
request.execute()
... I am getting the following error: Must request READ_SOURCE_TYPE_CONTACT
. Full traceback:
Traceback (most recent call last):
File "C:\Users\Leo\workspace\gapitest\main.py", line 22, in <module>
response = request.execute()
File "C:\Users\Leo\workspace\gapitest\venv\lib\site-packages\googleapiclient\_helpers.py", line 131, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\Leo\workspace\gapitest\venv\lib\site-packages\googleapiclient\http.py", line 937, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://people.googleapis.com/v1/otherContacts?readMask=names%2CemailAddresses%2CphoneNumbers&sources=READ_SOURCE_TYPE_PROFILE&pageSize=1000&alt=json returned "Must request READ_SOURCE_TYPE_CONTACT". Details: "Must request READ_SOURCE_TYPE_CONTACT">
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所看到的内容可能是一个错误。
我已在问题跟踪器上提交了此问题此处,因此请随意为其加注星标并最终添加评论,因为任何更新都将发布在那里。
It seems that what you are seeing might be a bug.
I have filed this issue on Issue Tracker here so feel free to star it and eventually add a comment, as any updates shall be posted there.
根据 Google 文档:
同时设置 READ_SOURCE_TYPE_CONTACT 和 READ_SOURCE_TYPE_PROFILE 应该可以解决此问题。
According to Google's documentation:
Setting both
READ_SOURCE_TYPE_CONTACT
andREAD_SOURCE_TYPE_PROFILE
should resolve this issue.