Announcements

Help Wizard

Step 1

NEXT STEP

401 Permissions missing. When Attempting to Play Track.

401 Permissions missing. When Attempting to Play Track.

I am trying to play a track on my app using spotify-web-api-node: 

https://github.com/caseysiebel/spotify-clone/blob/main/components/Song.tsx#L19

 

When I fire off this call to spotifyApi.play(), I am getting this error back WebapiRegularError: An error occurred while communicating with Spotify's Web API. Details: Permissions missing. with error code 401.

I have the accessToken and refreshToken set in my app. I am able to log in and get data from the API such as user, playslist and track data. But when I try to play a track, it's says I don't have permission.

I thought this might have something to do with how I've set the scopes in the Spotify API, but they look correct to me: 

https://github.com/caseysiebel/spotify-clone/blob/main/lib/spotify.ts#L5

Does anyone see what could be causing this issue with the missing persmisions issue and the Spotify API?

Reply
6 Replies

So I woke up this morning and fired up the app and it just worked as expected. Then an hour into working, it stopped working. Same 401, permissions issue. In all likelihood, this is an issue with Spotify's API, yeah? It's just weird that it worked for one hour and now it's broken again.

Hi leptone,

I see you're having the same issue as me and I tried to find out what's the problem here and, I couldn't find it at all. By the way, I don't know whether this is an issue from the Spotify API (Which I think the issue is coming from the API for what you wrote here) but probably should be cool for someone from the staff/developers to reply to this kind of problem tho.


I hope we can solve the issue really soon. 
If you solve the problem please lemme know.

Hi, 

im having kind of the same problem but with the autentication level:

client_credentials_manager = SpotifyClientCredentials(client_id="XXXXXXX", client_secret="XXXXXX")
spotify = spotipy.Spotify(client_credentials_manager=client_credentials_manager)

 Having this working days ago in an app, today it returns "401 Client Error: Unauthorized for url" when "spotify.me()". Have tried creating a new app with new credentials, but same problem.

I hope we can solve the issue really soon. 
If you solve the problem please let me know!

I also randomly receive this error when trying to call any of the player methods (play, pause, seek, etc).

Hello I don't know if you already found your answer but I too had the same problem here is how I fixed it.
When using spotipy some actions need more authentication, you can use OAuth: 

import spotipy
from spotipy.oauth2 import SpotifyOAuth
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id, client_secret, scope=scope, redirect_uri="http://localhost:9090"))

 For the scope, check with the Spotify console for your needs and get the scope need for the token.

The redirect_uri needs to be set in your apps settings, Dashboard  once its set make sure that they are the same, I recommend a 'http://127.0.0.1:9090' or a 'http://localhost:9090' port does not matter, this creates a new window in your web browser to give permissions.

 

Once this is done your code should be working as normal.

i have came across this issue and fixed it . follow below checkpoints

premium user

Web Playback SDK  type app in dashboard

streaming scope
 
key is scope and not scopes
const params = {
    scope:scopeString
  }
 

Suggested posts