From 164d8ecbebbb9ca1213b9915b4d6c445f1c3ba30 Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Tue, 13 Jun 2017 08:58:10 +1200 Subject: [PATCH] Preparing for Mopidy-Spotify 3.1.0 client credentials; Additional debug examples --- mopidy_iris/core.py | 28 ++++++++++++++++++++++++---- src/js/views/Debug.js | 18 +++++++++++++++++- src/scss/global/_forms.scss | 6 ++---- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/mopidy_iris/core.py b/mopidy_iris/core.py index 53d3a2de..616cda88 100755 --- a/mopidy_iris/core.py +++ b/mopidy_iris/core.py @@ -445,12 +445,25 @@ class IrisCore(object): } def refresh_spotify_token(self, data): - - url = 'https://accounts.spotify.com/api/token' - authorization = 'YTg3ZmI0ZGJlZDMwNDc1YjhjZWMzODUyM2RmZjUzZTI6ZDdjODlkMDc1M2VmNDA2OGJiYTE2NzhjNmNmMjZlZDY=' + ## TODO: See if we can use the credentials used by Mopidy-Spotify 3.1.0 + # Currently this returns 'invalid_client' error + + # Use client_id and client_secret from config + # This was introduced in Mopidy-Spotify 3.1.0 + #if 'spotify' in self.config and 'client_id' in self.config['spotify']: + # authorization = str(self.config['spotify']['client_id']+':'+self.config['spotify']['client_secret']) + # authorization = authorization.encode('base64').replace('\n', '') + + # Mopidy-Spotify is old version, so just use basic authorization code + #else: + # authorization = 'YTg3ZmI0ZGJlZDMwNDc1YjhjZWMzODUyM2RmZjUzZTI6ZDdjODlkMDc1M2VmNDA2OGJiYTE2NzhjNmNmMjZlZDY=' + + authorization = 'YTg3ZmI0ZGJlZDMwNDc1YjhjZWMzODUyM2RmZjUzZTI6ZDdjODlkMDc1M2VmNDA2OGJiYTE2NzhjNmNmMjZlZDY=' + url = 'https://accounts.spotify.com/api/token' headers = {'Authorization' : 'Basic ' + authorization} data = {'grant_type': 'client_credentials'} + data_encoded = urllib.urlencode( data ) req = urllib2.Request(url, data_encoded, headers) @@ -465,5 +478,12 @@ class IrisCore(object): }) return self.get_spotify_token({}) + except urllib2.HTTPError as e: - return e + error = json.loads(e.read()) + + return { + 'type': 'error', + 'message': 'Could not refresh token: '+error['error'], + 'source': 'refresh_spotify_token' + } diff --git a/src/js/views/Debug.js b/src/js/views/Debug.js index 350fb4ce..b35f20e1 100755 --- a/src/js/views/Debug.js +++ b/src/js/views/Debug.js @@ -25,7 +25,7 @@ class Debug extends React.Component{ this.state = { mopidy_call: 'playlists.asList', mopidy_data: '{}', - pusher_data: '{"method":"broadcast","data":{"type":"browser_notification","title":"Testing","body":"This is my message"}}' + pusher_data: '{"method":"get_config"}' } } @@ -151,6 +151,22 @@ class Debug extends React.Component{

Pusher

this.callPusher(e)}> +
+
Examples
+
+ +
+
Data
diff --git a/src/scss/global/_forms.scss b/src/scss/global/_forms.scss index 7ad520e3..b778319a 100755 --- a/src/scss/global/_forms.scss +++ b/src/scss/global/_forms.scss @@ -13,7 +13,8 @@ input[type="text"], input[type="email"], input[type="number"], input[type="email"], -input[type="date"] { +input[type="date"], +select { padding: 10px 14px; background: #FFFFFF; color: #000000; @@ -304,7 +305,6 @@ input[type="submit"] { &.radio, &.checkbox { - input{ display: none; } @@ -324,7 +324,6 @@ input[type="submit"] { } &.radio { - input + .label:before { content: ' '; display: inline-block; @@ -355,7 +354,6 @@ input[type="submit"] { } &.checkbox { - input + .label:before { font-family: FontAwesome; font-size: 8px;