[GH-ISSUE #772] Error 401 while trying to use 'recommendations' function #472

Closed
opened 2026-02-27 23:22:50 +03:00 by kerem · 2 comments
Owner

Originally created by @royanglister on GitHub (Jan 15, 2022).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/772

Hello,
I have been trying to use this function: recommendations(seed_artists=None, seed_genres=None, seed_tracks=None, limit=20, country=None, **kwargs) (syntax taken from Spotipy website), but Error 401 keeps popping up while saying that I did not provide any token. I've tried both SpotifyClientCredentials and SpotifyOAuth (which I am currently using) for authentication but still got no luck. It appears that there is no visible way for me to manually pass the access token through the function call as well. What am I missing?
Would appreciate any help from you guys.

Best,
Roy.

Originally created by @royanglister on GitHub (Jan 15, 2022). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/772 Hello, I have been trying to use this function: `recommendations(seed_artists=None, seed_genres=None, seed_tracks=None, limit=20, country=None, **kwargs)` (syntax taken from [Spotipy website](https://spotipy.readthedocs.io/en/2.19.0/#spotipy.client.Spotify.recommendations)), but Error 401 keeps popping up while saying that I did not provide any token. I've tried both `SpotifyClientCredentials` and `SpotifyOAuth` (which I am currently using) for authentication but still got no luck. It appears that there is no visible way for me to manually pass the access token through the function call as well. What am I missing? Would appreciate any help from you guys. Best, Roy.
kerem 2026-02-27 23:22:50 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@stephanebruckert commented on GitHub (Jan 16, 2022):

@royanglister how did you fix it? your solution could be useful for others in the future

<!-- gh-comment-id:1013963030 --> @stephanebruckert commented on GitHub (Jan 16, 2022): @royanglister how did you fix it? your solution could be useful for others in the future
Author
Owner

@royanglister commented on GitHub (Jan 17, 2022):

@stephanebruckert I've looked at previous issues regarding this error (Error 401: no token provided) and noticed that in 99% of the times, the error popped up because there was something wrong with the structure of the arguments delivered in the request function, and not actually because of the token itself.
Then I started experiencing with different parameters in this request simulator by Spotify in order to try figuring out what the problem is.
In my case, I found out that my mistake was passing the seed artists list as a list of artist URIs, as I should've passed it as a list of artist IDs. Another mistake of mine was to think that every seed list (artists, genres, and tracks) can contain up to 5 values, while the total sum of the values should've been up to 5. For example: 2 artists, 2 genres, and 1 track, and not up to 5 values in each list.

<!-- gh-comment-id:1014357664 --> @royanglister commented on GitHub (Jan 17, 2022): @stephanebruckert I've looked at previous issues regarding this error (Error 401: no token provided) and noticed that in 99% of the times, the error popped up because there was something wrong with the structure of the arguments delivered in the request function, and not actually because of the token itself. Then I started experiencing with different parameters in this [request simulator](https://developer.spotify.com/console/get-recommendations/) by Spotify in order to try figuring out what the problem is. In my case, I found out that my mistake was passing the seed artists list as a list of artist URIs, as I should've passed it as a list of artist IDs. Another mistake of mine was to think that every seed list (artists, genres, and tracks) can contain up to 5 values, while the total sum of the values should've been up to 5. For example: 2 artists, 2 genres, and 1 track, and not up to 5 values in each list.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#472
No description provided.