Repository navigation
feat(auth): Support a fixed OAuth redirect host/port - #106
Open
harrisonhjones wants to merge 1 commit into
Open
harrisonhjones wants to merge 1 commit into
harrisonhjones wants to merge 1 commit into
Conversation
The OAuth fallback always ran run_local_server(port=0): a random localhost port that a browser on another machine can't reach, so the server couldn't be authorized when it runs remotely. Add three optional env vars. OAUTH_HOST and OAUTH_PORT set where the callback listener binds (default localhost on a random port, as before; wildcard addresses are refused). OAUTH_REDIRECT_BASE sets a public HTTPS URL, such as a tunnel, that forwards to that port: Google is sent <base>/oauth2callback as the redirect URI, the authorization URL is logged to stderr instead of opening a browser, and a small listener on the fixed loopback port completes the token exchange. With all three unset, behavior is unchanged.
harrisonhjones
marked this pull request as ready for review
October 21, 2026 14:21
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.
What this changes
Adds three optional environment variables that let you complete the Google login when the server runs on a remote or headless machine and your browser is somewhere else. Nothing changes when they're unset.
Why
The OAuth login calls
run_local_server(port=0), which sends Google's redirect to a randomlocalhostport. A browser on another machine can't reach that, so the server can't be authorized there.How to use it
OAUTH_HOSTlocalhost;0.0.0.0and other wildcards are refused)OAUTH_PORT0, a random port; required withOAUTH_REDIRECT_BASE)OAUTH_REDIRECT_BASEWith a redirect base set, Google is sent
<base>/oauth2callbackas the redirect URI, and the login URL is logged to stderr instead of opening a browser. This needs a Web application OAuth client with<base>/oauth2callbackadded as an authorized redirect URI. Bothwebandinstalledclient JSON files load.Prior art
The same feature was merged in the Google Calendar MCP as
GOOGLE_OAUTH_REDIRECT_BASE: nspady/google-calendar-mcp#198. This change follows its design: a fixed loopback bind and a validated HTTPS base URL.Testing
tests/test_oauth_flow.pycovers the default and fixed binds, input validation, and a full callback over HTTP for both client formats (only the token exchange with Google is faked).