Patching broken spotify token refresher

This commit is contained in:
James Barnsley
2017-10-14 20:25:21 +13:00
parent f251974b0e
commit a9e07f70d1
3 changed files with 6 additions and 7 deletions

View File

@ -636,8 +636,9 @@ class IrisCore(object):
}
try:
response = requests.post(url, data)
self.spotify_token = response.json()
http_client = tornado.httpclient.AsyncHTTPClient()
request = tornado.httpclient.HTTPRequest(url, method='POST', body=urllib.urlencode(data))
http_client.fetch(request, callback=callback)
self.broadcast(
data={
@ -646,8 +647,6 @@ class IrisCore(object):
}
)
return self.get_spotify_token(callback=callback)
except urllib2.HTTPError as e:
self.raven_client.captureException()
error = json.loads(e.read())
@ -724,7 +723,7 @@ class IrisCore(object):
# Our request includes data, so make sure we POST the data
if ('data' in data and data['data']):
http_client = tornado.httpclient.AsyncHTTPClient()
request = tornado.httpclient.HTTPRequest(data['url'], method='POST', data=data['data'], headers=headers, validate_cert=False)
request = tornado.httpclient.HTTPRequest(data['url'], method='POST', body=json.dumps(data['data']), headers=headers, validate_cert=False)
http_client.fetch(request, callback=callback)
# No data, so just a simple GET request

View File

@ -201,6 +201,7 @@ class HttpHandler(tornado.web.RequestHandler):
# when our request calls subsequent external requests (eg Spotify, Genius).
# We don't need to wrap non-HTTPResponse responses as these are dicts
if isinstance(response, tornado.httpclient.HTTPResponse):
print response.body
response = {
'response_code': response.code,
'response_reason': response.reason,

View File

@ -26,8 +26,7 @@ setup(
'Mopidy-Local-Images >= 1.0',
'ConfigObj >= 5.0.6',
'raven >= 6.1.0',
'requests >= 2.0.0',
'promise >= 2.0.1'
'requests >= 2.0.0'
],
classifiers=[
'Environment :: No Input/Output (Daemon)',