def __call__(self):
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Cache-Control": "no-cache",
}
body = urlparse.urlencode({
"client_id": self.api_key,
"client_secret": self.client_secret,
"jwt_token": self.jwt_token
})
r = requests.post(self.endpoint, headers=headers, data=body)
if r.status_code != 200:
raise RuntimeError("Unable to authorize against {}:\n"
"Response Code: {:d}, Response Text: {}\n"
"Response Headers: {}]".format(self.endpoint, r.status_code, r.text, r.headers))
self.set_expiry(r.json()['expires_in'])
return r.json()['access_token']
评论列表
文章目录