3

I'm trying to use the Spotify API with the spotipy.py python module. I saw a specific example in several places and everyone says it works. this is the code:

CLIENT_ID = '3de0e551d7ad4f53928abdef515150ed'
CLIENT_SECRET = '6c77d106a8e843508bc7569f9a0f8397'
USER = 'd03ueir6zw7k1dyywjc97fee2?si=GVU-LsDRTg2vL5KPMTbfJg'

client_credentials_manager = SpotifyClientCredentials(client_id=CLIENT_ID,
                                                      client_secret=CLIENT_SECRET)
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
sp.trace = False

plists = sp.user_playlists(USER)

print(plists)

Of course in the original code, I put my real client id and secret.

However, when I run this code I'm getting an API response that says "No Token Provided".

{
  "error": {
    "status": 401,
    "message": "No token provided"
  }
}

I know you need to get permissions for some actions, but I thought the client credentials manager takes care of the permissions for me.

How do I make this code work? And what permissions are given to me using the client credentials manager?

squaleLis
  • 6,116
  • 2
  • 22
  • 30
DJ E.T
  • 31
  • 4

1 Answers1

0

You can't access user-specific information with just a Client ID and secret, even if you try and access your Spotify account which is the developer of the Spotify integration. You can access endpoints that provide public info, like artist & track info.

If you want to access user-specific data you need to go through the authorization code flow to get an access token that you provide to the Spotify client object instead.

Spotipy docs about authorization code flow

Rach Sharp
  • 2,324
  • 14
  • 31