mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-04 23:17:48 +00:00
Support both Python 2 & 3 base64 library
This commit is contained in:
parent
a3a68be7bc
commit
a541b3bb81
@ -62,8 +62,12 @@ class SpotifyClientCredentials(object):
|
||||
"""Gets client credentials access token """
|
||||
payload = { 'grant_type': 'client_credentials'}
|
||||
|
||||
auth_header = base64.b64encode(self.client_id + ':' + self.client_secret)
|
||||
headers = {'Authorization': 'Basic %s' % auth_header}
|
||||
if sys.version_info[0] >= 3: # Python 3
|
||||
auth_header = base64.b64encode(str(self.client_id + ':' + self.client_secret).encode())
|
||||
headers = {'Authorization': 'Basic %s' % auth_header.decode()}
|
||||
else: # Python 2
|
||||
auth_header = base64.b64encode(self.client_id + ':' + self.client_secret)
|
||||
headers = {'Authorization': 'Basic %s' % auth_header}
|
||||
|
||||
response = requests.post(self.OAUTH_TOKEN_URL, data=payload,
|
||||
headers=headers, verify=True)
|
||||
|
Loading…
Reference in New Issue
Block a user