Fix 403 errors for Spotify playlists saved from other users#94
Merged
bjarneo merged 3 commits intoMar 16, 2026
Merged
Conversation
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>
There was a problem hiding this comment.
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/melookup (cached) to get the current user’s Spotify ID and filter/v1/me/playlistsresults by ownership/collaboration. - Expand requested playlist fields to include
owner.idandcollaborativefor 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.
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>
Owner
|
Makes sense to add this. I wonder, down the road, if we should look into if you can play playlists that are not yours 🤔 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/v1/me/playlistsreturns 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./v1/me(cached after first call) and filter the playlist list to only show playlists the user owns or collaborates on.Test plan
403 ForbiddenerrorsFixes #89
🤖 Generated with Claude Code