OAuth2Decorator是否存储用户凭据并续订令牌?

时间:2013-05-10 19:09:16

标签: python google-app-engine google-drive-api

我正在使用OAuth2Decorator()和Pytgon我正处于那个阶段,我仍然不确定App Engine的内容。文档没有提供任何信息,或者我根本无法遵循它。所以:

  

OAuth2Decorator()是否存储用户Crediantials?

     

OAuth2Decorator()会自动检索新标记吗?

考虑以下示例。:

decorator = OAuth2Decorator(...)
service = build("drive", "v2")

class AppHandler(BaseHandler):
    @decorator.oauth_aware
    def get(self):
        if decorator.has_credentials():
            init = service.files().list().execute(decorator.http())
            items = init['items']
            context = {'data': getitems(items)}
            self.render_response('index.html',**context)
        else:
            url = decorator.authorize_url()
            self.redirect(url)

1 个答案:

答案 0 :(得分:3)

凭据在数据存储区中存储为CredentialsModel。

如果请求的访问权限是“离线”(我相信这是默认设置),那么临时访问令牌旁边会存储一个“刷新令牌”。如果使用凭据包装的Http客户端发出请求,则在收到指示访问令牌已过期的响应后,客户端会请求自动获取新的访问令牌,然后将使用新请求重试原始请求访问令牌,然后存储在已过期的令牌中。