ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!

Jump to content



Photo

Spotify API Help


  • Please log in to reply
Spotify API Help

#1

SmileyTM
SmileyTM
    Offline
    14
    Rep
    11
    Likes

    succ on my toes

Posts: 67
Threads: 6
Joined: Sep 02, 2018
Credits: 0

Five years registered
#1

I'm trying to make an API Spotify checker on Python

 

I was able to get this code working, but I noticed something that could potentially create a bug in my system.

 

With this code (having inputted bad login:pass):

with requests.Session() as c:
                header={
                'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/14A403 Safari/602.1',
                'Content-type': 'application/x-www-form-urlencoded',
                'Accept': 'application/json, text/plain, */*',
                }
                c.cookies.set('__bon', 'MHwwfC0xNDAxNTMwNDkzfC01ODg2NDI4MDcwNnwxfDF8MXwx')
                get = c.get('https://accounts.spotify.com/en/login?continue=https:%2F%2Fwww.spotify.com%2Fus%2Faccount%2Foverview%2F')
                print(get.content)
                if 'Spotify</title>' in str(get.content):
                    csrftoken = get.cookies['csrf_token']
                    login_data = dict(remember="true",username=usr, password=pwd, csrf_token=csrftoken)
                    page = c.post('https://accounts.spotify.com/api/login', data=login_data, headers=header)
                    print(page.content)
                    if 'displayName' in str(page.content):
                        valid = False
                        page = c.post('https://www.spotify.com/us/account/overview/', data=login_data, headers=header)
                        if 'Manage your family accounts' in str(page.content):
                            print("You are family owner")
                            valid = True

I get 

b'{"error":"errorInvalidCredentials"}'

BUT, when I remove 

c.cookies.set('__bon', 'MHwwfC0xNDAxNTMwNDkzfC01ODg2NDI4MDcwNnwxfDF8MXwx')

and I put a valid login credentials, I get the same error 

b'{"error":"errorInvalidCredentials"}'

Which essentially means if Spotify ever changes the cookie or it expires, all accounts will return that error...which is a huge no no when making an auto account replacement.

 

Any suggestions on how to prevent this from happening?


  • 1

#2

Hobokid
Hobokid
    Offline
    10
    Rep
    41
    Likes

    Advanced Member

Posts: 90
Threads: 54
Joined: Oct 10, 2018
Credits: 0

Five years registered
#2

due to whatever reason if spotify sends the user an email asking them to update their password, it gives same error  for Invalid Credentials untill the user updates their password. so if you do not have access to the registered email these accounts will not be retrieved and you will keep getting InvalidCredentials error.


  • 0
Bubbles#9572


 Users browsing this thread: