Skip to content

Conversation

@NikolayS
Copy link
Contributor

Problem

Fixes https://gitlab.com/postgres-ai/platform/-/issues/370

When a user has a custom apiBaseUrl in their CLI config, OAuth authentication fails with "OAuth session not found" because CLI and UI hit different backends.

Root Cause

  1. CLI calls oauth_init on configured API (e.g., staging v2.postgres.ai) → session created there
  2. UI calls oauth_approve on its default API (production postgres.ai) → session NOT found

Solution

Pass api_url parameter to the UI so it calls oauth_approve on the same backend where oauth_init created the session.

- const authUrl = `${uiBaseUrl}/cli/auth?state=...&redirect_uri=...`
+ const authUrl = `${uiBaseUrl}/cli/auth?state=...&redirect_uri=...&api_url=${apiBaseUrl}`

Related

claude and others added 2 commits December 28, 2025 19:05
The CLI uses the correct default API URL (postgres.ai/api/general/) which
successfully creates OAuth sessions. The "OAuth session not found" error
appears to be a backend issue where the UI at console.postgres.ai cannot
find sessions created by the API.

Changes:
- Add comprehensive unit tests for URL resolution and auth components
- Add CI smoke test to verify OAuth endpoint is reachable
- Clean up README examples to distinguish production vs staging environments

Note: The actual OAuth issue requires backend investigation - the API and UI
services may not be sharing session storage properly.
When user has a custom apiBaseUrl in config (e.g., staging v2.postgres.ai),
the CLI now passes this URL to the UI via api_url query param. This ensures
oauth_approve is called on the same backend where oauth_init created the session,
preventing 'OAuth session not found' errors due to API/UI backend mismatch.
@NikolayS NikolayS closed this Dec 30, 2025
@NikolayS NikolayS deleted the claude/fix-postgresai-auth-VPCNx branch December 30, 2025 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants