ARTICLE AD BOX
I've been working on a Python app that needs to call the Spotify API and access user playlists and items inside those playlists. Here is the code:
import os import base64 from requests import post, get import json clientid = "why would you want to see it" clientsecret = "no" def getToken(): auth_string = clientid + ":" + clientsecret auth_bytes = auth_string.encode("utf-8") auth_base64 = str(base64.b64encode(auth_bytes), "utf-8") url = "https://accounts.spotify.com/api/token" headers = { "Authorization": "Basic "+auth_base64, "Content-Type": "application/x-www-form-urlencoded" } data = { "grant_type": "client_credentials" } result = post(url, headers=headers, data=data) json_result = json.loads(result.content) token = json_result["access_token"] return token def get_auth_header(token): return {"Authorization": "Bearer "+token} def get_playlist(token, playlist_id): url = "https://api.spotify.com/v1/playlists/" headers = get_auth_header(token) query_url = url + playlist_id +"/tracks" result = get(query_url, headers=headers) print(token) print(query_url) print(result) token = getToken() get_playlist(token, "021tegZzZnT8YEpLr0lC3V")The playlist referenced in the last line is this public playlist.
I even tried to use the "search" call to search artists, but in any request I did, Spotify gave me a 403 forbidden, and if I use ThunderClient for the request, it gives me a 403 response and says I need Spotify premium.
My dashboard is here:
It says that I need premium, but why do the videos and tutorials I see (like this video) use the API without premium? People are going to use my program, and not everyone has premium.

