【发布时间】:2021-11-20 11:52:04
【问题描述】:
我是一个谷歌博客。 我每天使用 python 上传 10 个帖子。 上传了 25 篇帖子后,我要重新做一个凭证。
这是代码
CLIENT_SECRET = 'client_secret.json'
SCOPE = 'https://www.googleapis.com/auth/blogger'
STORAGE = Storage('credentials.storage')
# Start the OAuth flow to retrieve credentials
def authorize_credentials():
# Fetch credentials from storage
credentials = STORAGE.get()
# If the credentials doesn't exist in the storage location then run the flow
if credentials is None or credentials.invalid:
flow = flow_from_clientsecrets(CLIENT_SECRET, scope=SCOPE)
http = httplib2.Http()
credentials = run_flow(flow, STORAGE, http=http)
return credentials
credentials = authorize_credentials()
你知道有什么方法不用手动刷新凭证吗?
【问题讨论】:
-
您在 credentials.storage 文件中看到了什么?有刷新令牌吗?您在谷歌云控制台上的项目是否设置为测试?
标签: python oauth limit blogs credentials