403 Error Spotipy Playback Issues Playlist and Songs

Reply
Highlighted

403 Error Spotipy Playback Issues Playlist and Songs

Casual Listener

.

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 ?

6 Replies
Highlighted

Re: 403 Error Spotipy Playback Issues Playlist and Songs

Rock Star 16
Rock Star 16

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

HuboRock Star 16
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.
Highlighted

Re: 403 Error Spotipy Playback Issues Playlist and Songs

Casual Listener

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 

Highlighted

Re: 403 Error Spotipy Playback Issues Playlist and Songs

Casual Listener

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()
Highlighted

Re: 403 Error Spotipy Playback Issues Playlist and Songs

Rock Star 16
Rock Star 16

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 

HuboRock Star 16
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.
Highlighted

Re: 403 Error Spotipy Playback Issues Playlist and Songs

Casual Listener

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.

 

family.PNG

Highlighted

Re: 403 Error Spotipy Playback Issues Playlist and Songs

Rock Star 16
Rock Star 16

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

HuboRock Star 16
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.
SUGGESTED POSTS