client.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:hashtagtodo-open 作者: slackpad 项目源码 文件源码
def make_client(user):
    credentials = AUTHOMATIC.credentials(user.credentials)

    # The token refresh will be a no-op if it's not due to expire soon.
    orig_token = credentials.token
    credentials.refresh(soon=TOKEN_REFRESH_SECONDS)
    if credentials.token != orig_token:
        user.credentials = credentials.serialize()
        user.put()

    # TODO - The code from here down will only work for Google clients. We
    # should generalize a bit.

    # The refresh here should never be used, but we add it here just so
    # requests will go through if we get into a weird state.
    oauth_credentials = oauth2client.client.OAuth2Credentials(
        access_token=credentials.token,
        client_id=credentials.consumer_key,
        client_secret=credentials.consumer_secret,
        refresh_token=credentials.refresh_token,
        token_expiry=credentials.expiration_date,
        token_uri=credentials.provider_class.access_token_url,
        user_agent=USER_AGENT)

    http = httplib2.Http()
    http = oauth_credentials.authorize(http)
    return DiscoveryDocument.build('calendar', 'v3', http=http)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号