feat(api): Discogs OAuth callback flow (no more PIN copy/paste)#373
Merged
Conversation
…fier code
When DISCOGS_OAUTH_CALLBACK_URL is configured (and registered on the Discogs
developer app settings page), the OAuth 1.0a flow redirects users back to a
new static callback page on the Explore frontend instead of showing a PIN
for the user to copy/paste. The page posts the verifier code back to the
opening window via postMessage and self-closes, eliminating the manual
copy/paste step.
Without DISCOGS_OAUTH_CALLBACK_URL set, the existing out-of-band (OOB) modal
flow is preserved as the fallback for self-hosters with no public HTTPS host.
The authorize endpoint now returns a callback_mode field ("callback" or
"oob") so the frontend can branch deterministically. The popup listener
validates message origin and source before trusting the verifier code.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Adds Vitest coverage for the previously-uncovered branches in _registerDiscogsOAuthMessageListener flagged by Codecov on PR #373: - null message data is ignored - messages from a foreign window source are ignored - 'denied' error from the popup triggers cancellation alert + state clear - non-denied error from the popup triggers generic failure alert - oauth_token / stored state mismatch bails without calling verify - missing auth token at message time bails without calling verify - verify returning {connected:false} triggers failure alert - verify returning null triggers failure alert - a second startDiscogsOAuth call tears down the prior listener so stray messages from the original popup cannot complete the new flow Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Contributor
Contributor
Contributor
Contributor
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
Add an alternative Discogs OAuth flow that uses a real callback URL instead of the OAuth 1.0a out-of-band (OOB) mode, eliminating the "copy this PIN from Discogs" step that's currently shown to every user.
When the new `DISCOGS_OAUTH_CALLBACK_URL` env var is set and matches the Callback URL field on the Discogs developer app settings page, the flow becomes:
When `DISCOGS_OAUTH_CALLBACK_URL` is unset, behavior is unchanged: the existing OOB modal still works as a fallback for self-hosters with no public HTTPS host. The authorize endpoint now returns a `callback_mode` field (`"callback"` or `"oob"`) so the frontend branches deterministically.
Changes
Test plan
🤖 Generated with Claude Code