rspotify 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rspotify/connection.rb +12 -5
- data/lib/rspotify/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdb5d05c82ca5e425422843ec89590e50eeda168
|
4
|
+
data.tar.gz: e3178dcd15a55d6efff239aa384b4a2c48a2f721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb4206df7dd0b654bd9186488027f047ceba828b7db72a870f8775b8f068b668cf8d722a2af2ceb4dc701f710e98fdb990d1c8739436c30401f5e17e5e02519e
|
7
|
+
data.tar.gz: f83a6ee536693dd4616811a1fcc965f788680ca4b6c09296667e5f5c8a6c7e80c9e10b4cf45f5e29bef683b42629d84e7116f0cdda54c9730a4c4c76f747190b
|
data/lib/rspotify/connection.rb
CHANGED
@@ -59,14 +59,16 @@ module RSpotify
|
|
59
59
|
url << "?#{query}" if query
|
60
60
|
|
61
61
|
begin
|
62
|
+
headers = get_headers(params)
|
63
|
+
headers['Accept-Language'] = ENV['ACCEPT_LANGUAGE'] if ENV['ACCEPT_LANGUAGE']
|
62
64
|
response = RestClient.send(verb, url, *params)
|
63
65
|
rescue RestClient::Unauthorized => e
|
64
66
|
raise e if request_was_user_authenticated?(*params)
|
65
67
|
if @client_token
|
66
68
|
authenticate(@client_id, @client_secret)
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
+
headers = get_headers(params)
|
71
|
+
headers['Authorization'] = "Bearer #{@client_token}"
|
70
72
|
|
71
73
|
response = retry_connection verb, url, params
|
72
74
|
end
|
@@ -86,11 +88,11 @@ module RSpotify
|
|
86
88
|
User.class_variable_get('@@users_credentials')
|
87
89
|
end
|
88
90
|
|
89
|
-
|
90
|
-
if users_credentials
|
91
|
+
headers = get_headers(params)
|
92
|
+
if users_credentials
|
91
93
|
creds = users_credentials.map{|user_id, creds| "Bearer #{creds['token']}"}
|
92
94
|
|
93
|
-
if creds.include?(
|
95
|
+
if creds.include?(headers['Authorization'])
|
94
96
|
return true
|
95
97
|
end
|
96
98
|
end
|
@@ -101,5 +103,10 @@ module RSpotify
|
|
101
103
|
authorization = Base64.strict_encode64 "#{@client_id}:#{@client_secret}"
|
102
104
|
{ 'Authorization' => "Basic #{authorization}" }
|
103
105
|
end
|
106
|
+
|
107
|
+
def get_headers(params)
|
108
|
+
params.find{|param| param.is_a?(Hash) && param['Authorization']}
|
109
|
+
end
|
110
|
+
|
104
111
|
end
|
105
112
|
end
|
data/lib/rspotify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspotify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Sad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|