Repository navigation
Keep the Spotify example login callback on loopback - #552
Merged
Merged
Conversation
Serve the one-shot callback page from memory and finish denied, repeated, and missing-token requests explicitly. Document the matching redirect URI and cover the listener with offline tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The Spotify login callback changes have no active review issues.
No open issues 🎉
What changed in this PR
This PR confines the TypeScript music example’s Spotify login callback to IPv4 loopback and removes request-time HTML file access, without changing the TypeChat library.
Changes:
- Bind the login server and redirect URI to
127.0.0.1, with updated setup instructions. - Preload callback HTML, reject repeat callbacks, and close the listener on successful or failed authorization.
- Add three offline tests covering loopback binding, callback handling, and listener shutdown.
| File | Description |
|---|---|
typescript/tests/examples.test.mjs |
Adds offline login tests using loopback requests and a stubbed browser. |
typescript/examples/music/src/authz.ts |
Restricts binding to loopback, preloads HTML, and handles authorization completion and errors. |
typescript/examples/music/README.md |
Documents the loopback redirect URI and migration from localhost. |
Review effort: Balanced
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.
The TypeScript music example now binds its login server to
127.0.0.1and uses that same address in the Spotify redirect URI. Existing users of the example should registerhttp://127.0.0.1:PORT/callbackin their Spotify app settings in place of the oldlocalhostURI.The server loads the HTML page once, before it starts listening. The first callback serves it from memory; a repeat gets
410 Gone. A denied login or missing token gets an explicit error and closes the listener so the CLI can continue without Spotify. This removes the request-time file access flagged by code scanning alert 4 without adding middleware or changing the TypeChat library.Verification (Node 24.22.1):
npm run build-allandnpm testpassed; all 594 tests passed. Three new offline tests use real loopback requests and a stubbed browser; they cover the bind address and redirect URI, serving after the page file is removed, repeat callbacks, and shutdown on success and failure. Live Spotify sign-in was not exercised.