Type in your question below and we'll check to see what answers we can find...
Loading article...
Submitting...
If you couldn't find any answers in the previous step then we need to post your question in the community and wait for someone to respond. You'll be notified when that happens.
Simply add some detail to your question and refine the title if needed, choose the relevant category, then post.
Before we can post your question we need you to quickly make an account (or sign in if you already have one).
Don't worry - it's quick and painless! Just click below, and once you're logged in we'll bring you right back here and post your question. We'll remember what you've already typed in so you won't have to do it again.
.
Plan
Premium
Country
France
Operating System
Windows 10
My Question or Issue
Was trying to play a playlist using the spotipy library and my credentials. Was able to get the playlist metadata but when trying to play a song or a playlist I got a 403 error saying that my account is not prenium even though it is. Or is it because it is a family prenium account ?
Do you have any idea or similar issues with the spotipy library ?
Hey @Narakap, thanks for reaching out!
That doesn't sound right! First things first, could you make sure you're authenticated with the right account? You can check by verifying that:
spotipy.me()
shows the correct username. Let me know if that works.
Have a good one!
Hubo
Hello, Ty for your reply.
When trying your command I got that error :
HTTP Error for GET to https://api.spotify.com/v1/me/ returned 401 due to Unauthorized.
I checked and I got the latest version of spotipy avalaible here https://github.com/plamere/spotipy.git
Here is Mmy code between
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
import json
client_credentials_manager = SpotifyClientCredentials(client_id=my_client_id,client_secret=my_client_secret)
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
sp.me()
Hey @Narakap, thanks for getting back to me!
Gotcha! Let's dive into this. You can use export commands (in Terminal) to set the client_id and client_secret variables for your OS.
export SPOTIPY_CLIENT_ID=client_id_here export SPOTIPY_CLIENT_SECRET=client_secret_here // on Windows, use `SET` instead of `export`
Alternatively, you can in Python set them with these:
os.environ["SPOTIPY_CLIENT_ID"] = "(my client id)" os.environ["SPOTIPY_CLIENT_SECRET"] = "(my client secret)"
There's more information about this here: https://github.com/plamere/spotipy. Let me know if that helps here!
Have a good one,
Hubo
Ty for trying to help me.
I set the credentials like showed here https://github.com/plamere/spotipy
I managed to run the example code the gave without error :
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
import json
import os
os.environ["SPOTIPY_CLIENT_ID"] = my_client_id
os.environ["SPOTIPY_CLIENT_SECRET"] = my_secret_id
sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
results = sp.search(q='weezer', limit=20)
for idx, track in enumerate(results['tracks']['items']):
print(idx, track['name'])
But when I tried sp.me() it gave me the same error...
HTTP Error for GET to https://api.spotify.com/v1/me/ returned 401 due to Unauthorized.
Just to be sure again I checked and I am prenium.
Hey @Narakap,
Hmm, got it! You might need to adjust the scope of your authorization request to see the information from the ‘me’-endpoint. Are you able to access the other ‘scope-less’ endpoints? Let me know!
Have a good one,
Hubo
Hi all,
Im having the same problem with credentials ids. I've tried with:
os.environ["SPOTIPY_CLIENT_ID"] = my_client_id os.environ["SPOTIPY_CLIENT_SECRET"] = my_secret_id
set SPOTIPY_CLIENT_ID=client_id set SPOTIPY_CLIENT_SECRET=client_secret
client_credentials_manager = SpotifyClientCredentials(client_id=my_client_id,client_secret=my_client_secret) sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
In all the different ways, after doing "sp.me()" or "sp.current_user()" I get: "requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.spotify.com/v1/me/"
When requesting "sp.current_user_recently_played(limit=50)" i get: "HTTP Error for GET to https://api.spotify.com/v1/me/player/recently-played returned 403 due to Insufficient client scope"
It's my second project using Spotify API from Python, and this time I'm having big trouble just by getting the credentials.
Any help would be great!
Thanks!
The Client Credentials Flow (implemented by `SpotifyClientCredentials` in spotipy) does NOT support authorizing for a user. It's only used for requests that don't access user data. Obviously, `sp.me()` accesses user data. You need to use `SpotifyOAuth` or `SpotifyPKCE` for authorization instead.
Hey there you, Yeah, you! 😁 Welcome - we're glad you joined the Spotify Community! While you here, let's have a fun game and get…