I'm trying to run a python script that uses spotipy, which needs a url link to be opened to authenticate the login. unfortunately I'm running this on the google cloud shell, so I can't open the browser link. and for some reason when I open it in my browser, it just redirects to localhost and doesn't authenticate (localhost is the Redirect URI). how can I authenticate?
I've tried opening the link on my MacBook instead of the linux virtual machine but just got redirected to localhost and nothing happens. I've tried xdg-open, curl, but haven't gotten anywhere.
Edit: I tried this -
import spotipy import spotipy.util as util from config import CLIENT_ID, CLIENT_SECRET, PLAY_LIST, USER import random
token = util.oauth2.SpotifyClientCredentials(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
cache_token = token.get_access_token() spotify = spotipy.Spotify(cache_token)
results1 = spotify.user_playlist_tracks(USER, PLAY_LIST, limit=100, offset=0)
But got the error that only valid bearer authentication is accepted, so apparently it's kind of working. I'm not sure how to make the bearer valid.
Edit 2: Solved it with these posts: How to auth in spotipy without open web browser? Persistent issues with Spotify Web API redirect URI