Fix Deezer login
Deezer couldn't care less about the access_token
This commit is contained in:
9
dzapi.py
9
dzapi.py
@@ -72,6 +72,9 @@ class DeezerAPI:
|
|||||||
return resp['results']
|
return resp['results']
|
||||||
|
|
||||||
def login_via_email(self, email, password):
|
def login_via_email(self, email, password):
|
||||||
|
# server sends set-cookie header with new sid
|
||||||
|
self.s.get('https://www.deezer.com')
|
||||||
|
|
||||||
password = MD5.new(password.encode()).hexdigest()
|
password = MD5.new(password.encode()).hexdigest()
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
@@ -81,16 +84,12 @@ class DeezerAPI:
|
|||||||
'hash': MD5.new((self.client_id + email + password + self.client_secret).encode()).hexdigest(),
|
'hash': MD5.new((self.client_id + email + password + self.client_secret).encode()).hexdigest(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# server sends set-cookie header with account sid
|
||||||
json = self.s.get('https://connect.deezer.com/oauth/user_auth.php', params=params).json()
|
json = self.s.get('https://connect.deezer.com/oauth/user_auth.php', params=params).json()
|
||||||
|
|
||||||
if 'error' in json:
|
if 'error' in json:
|
||||||
raise self.exception('Error while getting access token, check your credentials')
|
raise self.exception('Error while getting access token, check your credentials')
|
||||||
|
|
||||||
headers = {'Authorization': f'Bearer {json["access_token"]}'}
|
|
||||||
|
|
||||||
# server sends set-cookie header with account sid
|
|
||||||
self.s.get('https://api.deezer.com/platform/generic/track/80085', headers=headers)
|
|
||||||
|
|
||||||
arl = self._api_call('user.getArl')
|
arl = self._api_call('user.getArl')
|
||||||
|
|
||||||
return arl, self.login_via_arl(arl)
|
return arl, self.login_via_arl(arl)
|
||||||
|
|||||||
Reference in New Issue
Block a user