Skip to content

fix(oauth): let a pinned base URL supply its own OAuth client ID - #1172

Closed
posthog[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixoauth-let-a-pinned-base-url-supply-47e003
Closed

fix(oauth): let a pinned base URL supply its own OAuth client ID#1172
posthog[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixoauth-let-a-pinned-base-url-supply-47e003

Conversation

@posthog

@posthog posthog Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Problem

  • A user who pointed the published wizard at their own PostHog instance with --base-url could not log in — the token endpoint answered invalid_client and login stopped completely.
  • getOAuthClientId has only two answers: the production proxy client, or the dev client whenever any base URL resolves. So every pinned run sends the dev client ID, which an instance that does not seed the dev OAuth app rejects.
  • --base-url is a hidden but fully live global flag in published builds (unlike the --local-* targets, which published builds reject), so this hits real self-hosted and local pinned runs.
  • Rare — the rarest OAuth login failure the wizard files — but a hard stop for the affected run.

Changes

  • Add a global --oauth-client-id flag (env POSTHOG_WIZARD_OAUTH_CLIENT_ID), hidden like --base-url.
  • An explicit client ID now wins in both getOAuthClientId (login) and getProvisioningClientId (signup); the base-URL and region defaults are unchanged when the flag is absent.
  • Thread the value from the session through the login and provisioning paths (getOrAskForProjectDataaskForWizardLoginperformOAuthFlow / provisionNewAccount), plus the Slack-connect, MCP-tutorial, provision, and CI-signup entry points.
  • The invalid_client remediation message now names --oauth-client-id as an alternative to seeding the OAuth app.
  • Removes the two TODOs in oauth.ts and provisioning.ts that proposed exactly this flag.

Test plan

  • New unit test: provisionNewAccount sends an explicit oauthClientId instead of the region client.
  • Updated unit test: the invalid_client message mentions --oauth-client-id.
  • pnpm build && pnpm test — all 2475 tests pass; pnpm lint — 0 errors.

LLM context

Authored by a PostHog scout agent. The fix follows the TODO the code already carried at src/utils/oauth.ts. Scoped strictly to client-ID selection — it does not change whether a fully explained config failure still files an exception (open PR #1131 makes that call for access_denied).


Created with PostHog Desktop from this inbox report.

Add a global `--oauth-client-id` flag (env `POSTHOG_WIZARD_OAUTH_CLIENT_ID`),
threaded through `getOAuthClientId` and `getProvisioningClientId`.

Before, any pinned `--base-url` run always sent the dev OAuth client ID, so a
self-hosted or local instance that does not seed the dev OAuth app answered
`invalid_client` and login could not complete. An explicit client ID now wins
over the base-URL heuristic; the base-URL and region defaults are unchanged when
the flag is absent. The `invalid_client` message now names the new flag.

Generated-By: PostHog Desktop
Task-Id: b221e56b-7a82-4bd3-8851-2ed08b422dc9
@posthog

posthog Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

🦔 PostHog Review reviewed this pull request

Found 0 must fix, 1 should fix, 0 consider.

Published 1 finding (view the review).

Resolved comments: 1 fixed

@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/groq
  • /wizard-ci ai-observability/manual-capture
Show more apps
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

@posthog
posthog Bot marked this pull request as ready for review August 31, 2026 12:35
@posthog
posthog Bot requested a review from a team as a code owner August 31, 2026 12:35
@posthog

posthog Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

PostHog Review alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostHog Review

Found 1 should fix.

Comment thread src/wizard.ts
`wizard mcp add` accepted the global --oauth-client-id flag but never
copied it into the session, so the Slack-connect and suggested-prompts
login screens fell back to the dev client ID and a pinned self-hosted
instance could still answer invalid_client — the exact failure this PR
fixes everywhere else. Pass oauthClientId to buildSession like the
sibling tutorial command, and cover both overrides in the command test.

Generated-By: PostHog Desktop
Task-Id: 4cbcaf4a-2fd7-429a-9c04-8a1a87e2f1fe
@sarahxsanders

Copy link
Copy Markdown
Collaborator

no one should be using this publically

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