api.py 文件源码

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

项目:sndlatr 作者: Schibum 项目源码 文件源码
def post(self):
        """
        Exchange client supplied oauth code for credentials.
        This does not require idtoken auth. User id is obtained form the
        oauth flow instead.
        """
        code = validation.auth_code_schema(self.json).get('code')
        try:
            credentials = auth.credentials_from_code(code)
        except FlowExchangeError:
            raise HTTPBadRequest('invalid code')
            # reject if we did not get a refresh token and id_token
        if not credentials.refresh_token:
            logging.warning('got no refresh token')
            raise HTTPForbidden('not initial code')
        id_token = credentials.id_token
        if id_token is None:
            raise HTTPForbidden('got no id token')
        try:
            email = id_token['email']
            user_id = id_token['sub']
        except KeyError:
            raise HTTPForbidden('no valid id')
        account = models.Account(email=email, id=user_id,
                                 credentials=credentials)
        account.put()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号