- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to make a user authentication using python scripts.
First I retrieve the auth_headers:
auth_headers = {
"client_id": client_id,
"response_type": "code",
"redirect_uri": "http://localhost:7777/callback",
"scope": "user-library-read"
}
r = webbrowser.open("https://accounts.spotify.com/authorize?" + urlencode(auth_headers))
Then I get the code from the callback url "code=..."
code = "...."
encoded_credentials = base64.b64encode(client_id.encode() + b':' + client_secret.encode()).decode("utf-8")
token_headers = {
"Authorization": "Basic " + encoded_credentials,
"Content-Type": "application/x-www-form-urlencoded"
}
token_data = {
"grant_type": "authorization_code",
"code": code,
"redirect_uri": "http://localhost:7777/callback"
}
r = requests.post("https://accounts.spotify.com/api/token", data=token_data, headers=token_headers)
So my problem is I have to run the first script to get the authorization code whenever I refresh. Is there anyway to automate this process? Thank you so much
Solved! Go to Solution.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page