Spotify API 403 Forbidden Error When Adding Tracks to Playlist Despite Correct Token and Scopes

I'm experiencing a 403 Forbidden error when trying to add a track to a Spotify playlist using the Spotify Web API. Despite having a correctly configured token and permissions, I’m still facing this issue.

Details:

Access Token Details:

{
  "access_token": "my access token",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "my refresh token",
  "scope": "playlist-modify-private playlist-modify-public playlist-read-private playlist-read-collaborative",
  "expires_at": 1725396428
}

Error Log:

INFO 2024-09-03 20:16:02,097 cron Distributing 1 playlists to job scheduled at 2024-09-03 20:47:02.097874 for Order ID 28.
INFO 2024-09-03 20:16:02,100 cron Adding track 0TT2Tzi8mEETCqYZ1ffiHh to playlist 4CeTjVTCZOFzTBdO8yaLvG
ERROR 2024-09-03 20:16:02,557 cron Spotify API error: https://api.spotify.com/v1/playlists/4CeTjVTCZOFzTBdO8yaLvG/tracks:
 Check settings on developer.spotify.com/dashboard, the user may not be registered.
ERROR 2024-09-03 20:16:02,558 cron Check if the user 31rizduwj674dch67g22bjqy7sue is correctly registered and has permissions to modify the playlist.

What I’ve Tried

1- Verified Token Scopes: The token includes scopes playlist-modify-private playlist-modify-public playlist-read-private playlist-read-collaborative.

2- Checked Token Validity: The token is valid and has not expired. I also attempted to refresh it.

3- Confirmed Playlist Ownership: Ensured that the playlist is either owned by or shared with the user whose token is being used.

4- Re-authenticated: Re-authenticated and re-authorized the application to confirm there are no issues with authentication.

5- API Endpoint & Request Format: Verified that the API endpoint and request format conform to the Spotify API documentation.

6- User Permissions: Confirmed that the user has the necessary permissions to modify the playlist.

Questions

1- Is there any additional configuration or setting I might be missing on the Spotify Developer Dashboard?

2- Could the issue be related to specific permissions or configurations for the playlist or user account?

3- Are there other common issues or troubleshooting steps for resolving 403 Forbidden errors with the Spotify API?

Environment Details:

  • Django latest
  • Spotipy for Spotify OAuth
  • Python 3.12
  • Ubuntu 22.04

Request sample - Curl:

curl --request POST \
  --url 'https://api.spotify.com/v1/playlists/6QoiIukPdZNHILKt4S7SDF/tracks?uris=spotify%3Atrack%3A0TT2Tzi8mEETCqYZ1ffiHh' \
  --header 'Authorization: Bearer 1POdFZRZbvb...qqillRxMr2z' \
  --header 'Content-Type: application/json' \
  --data '{
    "uris": [
        "spotify:track:0TT2Tzi8mEETCqYZ1ffiHh"
    ],
    "position": 0
}'

Any assistance or suggestions to resolve this issue would be greatly appreciated.

Back to Top