【发布时间】:2014-08-14 08:11:51
【问题描述】:
背景
- 我使用 google-api-python-client django_sample 获得了 Google API 的 access_token。
- 要离线访问,我添加了
FLOW.params['access_type'] = 'offline'。 - 已存储
credentials_json = credentials.to_json()。它包含一个refresh_token。 - 已恢复凭据
Credentials.new_from_json(credentials_json)。 - 使用此凭据通过
credentials.authorize(http)获得访问权限。 - 完美运行 =)
问题
- 我每 5 分钟做一次。
- 在每次迭代中,我都会存储凭据并打印出来。
- 1 小时 45 分钟后,“refresh_token”变为空。
- 此时代码停止工作 =(
我的问题
-
Credentials类会自动刷新它的令牌吗? - 如果没有,我应该在什么时候致电
credentials.refresh(http)?
谢谢!
【问题讨论】:
标签: google-oauth google-api-python-client oauth2client