【发布时间】:2016-12-02 09:01:02
【问题描述】:
这似乎是一个愚蠢的问题,但我在 google sdk 文档中的任何地方都找不到它。
如何从刚刚授权我离线访问其中一个 Google API 的用户帐户获取电子邮件地址 (xxxxx@gmail.com)?
import httplib2
import datetime
from apiclient import discovery
from oauth2client import client
json_credentials_as_string = "..."
credentials = client.OAuth2Credentials.from_json(json_credentials_as_string)
http_auth = credentials.authorize(httplib2.Http())
service = discovery.build('calendar', 'v3', http=http_auth)
# ...?
服务列表是here,但没有提及任何实际获取用户信息的内容。
This shows how to get the primary calendar(使用'primary' calendarId),这可能是他们的帐户电子邮件,但我不确定它必须是?如果有人更改了他们的主日历,似乎可能不会返回他们的谷歌电子邮件 ID (xxxx@gmail.com),这正是我想要的。
【问题讨论】:
标签: python oauth-2.0 google-calendar-api