当我发送帖子请求时,Tornado无法从中获取request.body。它来自我想要授权的服务文档:
POST https://www.wrike.com/oauth2/token 参数: CLIENT_ID = client_secret = grant_type = authorization_code 代码=
这是我的代码:
data = dict(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, grant_type="authorization_code", code=AUTHORIZATION_TOKEN)
API.get("https://www.wrike.com/oauth2/token", data=data, headers={})
处理程序:
class Handler(tornado.web.RequestHandler):
def post(self):
try:
data = tornado.escape.json_decode(self.request.body)
print "handler there", data
message = data["message"]
parseCommandFrom(message)
except Exception as e:
print e.message
def get(self):
text = self.request.uri
if "/?code=" in text:
getToken(text[7:])
self.write("Succes authorize.")
else:
self.write("Something went wrong...")