Skip to content

Fix 403 errors for Spotify playlists saved from other users#94

Merged
bjarneo merged 3 commits into
bjarneo:mainfrom
duobei:fix/spotify-403-inaccessible-playlists
Mar 16, 2026
Merged

Fix 403 errors for Spotify playlists saved from other users#94
bjarneo merged 3 commits into
bjarneo:mainfrom
duobei:fix/spotify-403-inaccessible-playlists

Conversation

@duobei
Copy link
Copy Markdown
Contributor

@duobei duobei commented Mar 16, 2026

Summary

  • /v1/me/playlists returns all playlists in the user's library including ones saved/followed from other users. The Spotify API returns 403 when trying to list tracks for these playlists.
  • Fetch the current user's ID via /v1/me (cached after first call) and filter the playlist list to only show playlists the user owns or collaborates on.
  • Add a clear error message for any remaining 403 errors explaining the limitation, instead of showing a raw HTTP error.

Test plan

  • Spotify playlists list no longer shows playlists saved from other users
  • Your own playlists and collaborative playlists still appear and load correctly
  • Opening a playlist no longer produces 403 Forbidden errors

Fixes #89

🤖 Generated with Claude Code

The Spotify API returns 403 when listing tracks for playlists owned
by other users, even when those playlists appear in /v1/me/playlists
(e.g. playlists you have saved/followed from other users).

Two changes:
- Filter /v1/me/playlists to only show playlists owned by the current
  user or marked as collaborative. Requires a single /v1/me call to
  get the user's ID (cached after first fetch).
- Show a clear error message when 403 occurs instead of the raw
  HTTP error, to help users who encounter it despite the filter.

Fixes bjarneo#89

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 16, 2026 13:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Spotify 403 Forbidden errors encountered when selecting playlists that are saved/followed from other users by filtering the playlist list to those the user owns or collaborates on, and by improving the surfaced error message for remaining 403s.

Changes:

  • Add lazy /v1/me lookup (cached) to get the current user’s Spotify ID and filter /v1/me/playlists results by ownership/collaboration.
  • Expand requested playlist fields to include owner.id and collaborative for filtering.
  • Add custom handling for HTTP 403 responses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread external/spotify/provider.go Outdated
Comment thread external/spotify/provider.go
duobei and others added 2 commits March 16, 2026 21:23
Refactor the playlist filtering condition into a named function
playlistAccessible() to make it independently testable without
any HTTP calls or mocking infrastructure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Move 403 error message from webAPI() into Tracks() where the context
  is known; avoids misleading message for /v1/me or other endpoints
- Clear cached userID in Close(), ensureSession(), and Authenticate()
  to prevent stale user ID filtering after re-authentication

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bjarneo
Copy link
Copy Markdown
Owner

bjarneo commented Mar 16, 2026

Makes sense to add this. I wonder, down the road, if we should look into if you can play playlists that are not yours 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERR: spotify: list tracks: http status 403 Forbidden: {"error": {"status": 403, "message": "Forbidden" } }

3 participants