def post(self):
"""Return a token"""
try:
grant = oauth2.get_grant(self.request)
except oauth2.InvalidGrantType:
raise exceptions.HTTPError(400, 'invalid_grant')
try:
token, expiry = yield grant.generate_token()
except (oauth2.InvalidScope, jwt.InvalidTokenError, ValueError) as exc:
raise exceptions.HTTPError(400, exc.args[0])
except oauth2.Unauthorized as exc:
raise exceptions.HTTPError(403, exc.args[0])
self.finish({
'status': 200,
'access_token': token,
'token_type': 'bearer',
'expiry': expiry
})
评论列表
文章目录