Skip to content

Skip OAuth1 browser flow when access tokens are pre-provided#1

Merged
bdr193 merged 1 commit into
masterfrom
feat/skip-oauth1-flow-when-tokens-set
Apr 30, 2026
Merged

Skip OAuth1 browser flow when access tokens are pre-provided#1
bdr193 merged 1 commit into
masterfrom
feat/skip-oauth1-flow-when-tokens-set

Conversation

@bdr193
Copy link
Copy Markdown
Collaborator

@bdr193 bdr193 commented Apr 30, 2026

Summary

Lets us deploy this fork to FastMCP Cloud / Horizon. build_oauth1_client always called run_oauth1_flow(), which opens a browser and binds a localhost listener on 127.0.0.1:8976 — a desktop flow that cannot run in a hosted build container.

When both X_OAUTH_ACCESS_TOKEN and X_OAUTH_ACCESS_TOKEN_SECRET are set, skip the browser flow and use them directly. Local behaviour is unchanged when either is unset.

Mirrors upstream PR: xdevplatform#14

Test plan

  • python -m py_compile server.py passes
  • Local run without env vars: unchanged — browser opens, OAuth1 completes
  • Local run with both env vars set: starts without opening a browser
  • Horizon build (fastmcp inspect) succeeds and /mcp serves over HTTPS

🤖 Generated with Claude Code

`build_oauth1_client` always called `run_oauth1_flow()`, which opens a
browser via `webbrowser.open` and binds a localhost listener on
127.0.0.1:8976 to receive the OAuth1 callback. This is a desktop flow
and cannot run in non-interactive environments — CI builds, hosted MCP
runtimes (e.g. FastMCP Cloud / Horizon), or anything without a display
and an in-process browser on the same machine.

When both `X_OAUTH_ACCESS_TOKEN` and `X_OAUTH_ACCESS_TOKEN_SECRET` are
set in the environment, use them directly and skip the browser flow.
Local behaviour is unchanged when either env var is unset — the
interactive flow still runs.

This also fixes a documentation/runtime mismatch: the README already
mentioned `X_OAUTH_ACCESS_TOKEN` as a way to supply a pre-generated
token, but the runtime never actually consumed it (it was only read by
`get_auth_headers`, which the request signing path doesn't use).

Workflow:

  1. Run locally once with `X_OAUTH_PRINT_TOKENS=1 python server.py`
     to complete the interactive flow and capture both values.
  2. Set the two env vars in your hosted environment.
  3. Subsequent startups skip the browser entirely.
@bdr193 bdr193 merged commit bdd9f2a into master Apr 30, 2026
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.

1 participant