Skip to content

docs: clarify OAuth callback setup for GitHub and Google#260

Open
mason5052 wants to merge 2 commits intovxcontrol:mainfrom
mason5052:codex/issue-219-oauth-docs
Open

docs: clarify OAuth callback setup for GitHub and Google#260
mason5052 wants to merge 2 commits intovxcontrol:mainfrom
mason5052:codex/issue-219-oauth-docs

Conversation

@mason5052
Copy link
Copy Markdown
Contributor

@mason5052 mason5052 commented Apr 15, 2026

Summary

  • clarify how PUBLIC_URL is used to build OAuth callback URLs
  • document the correct GitHub OAuth App values for Homepage URL and Authorization callback URL
  • add matching .env examples for GitHub and Google OAuth in both README.md and backend/docs/config.md

Problem

Issue #219 reports that the OAuth setup docs explain the client ID and secret, but do not explain what to use for the provider-side callback settings.

As a result, users can configure GitHub OAuth credentials and still hit redirect_uri mismatch errors because the required Homepage URL and Authorization callback URL values are not documented.

Solution

Document the callback construction used by PentAGI's router and make the provider configuration explicit:

  • Homepage URL = PUBLIC_URL
  • Authorization callback URL / Redirect URI = ${PUBLIC_URL}/api/v1/auth/login-callback

This PR also adds concrete .env examples, clarifies that PUBLIC_URL is the public origin/base URL, and notes that Google uses the same PentAGI callback endpoint.

User Impact

Users setting up GitHub or Google OAuth no longer need to infer callback values from the codebase. The required provider configuration is documented directly where the OAuth environment variables are explained.

Closes #219.

Test Plan

  • Verified the router builds the callback from PUBLIC_URL, baseURL, and /auth/login-callback in backend/pkg/server/router.go
  • Verified the README examples use existing environment variables from .env.example
  • Verified backend/docs/config.md matches the current router behavior
  • git diff --check

Signed-off-by: Mason Kim(ZINUS US_SALES) <mkim@zinus.com>
@mason5052 mason5052 marked this pull request as ready for review April 15, 2026 16:19
Copilot AI review requested due to automatic review settings April 15, 2026 16:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the documentation to make OAuth provider-side configuration (GitHub/Google callback settings) explicit, based on how PentAGI constructs redirect URIs from PUBLIC_URL.

Changes:

  • Clarifies how PUBLIC_URL is used to construct OAuth callback URLs.
  • Documents provider console values (Homepage URL / Redirect URI) for GitHub and Google.
  • Adds .env configuration examples for both providers in docs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
backend/docs/config.md Expands PUBLIC_URL/OAuth configuration guidance and adds provider-side callback setup + env examples.
README.md Adds explicit GitHub/Google OAuth setup steps and .env examples, emphasizing callback construction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/docs/config.md Outdated
| ----------------------- | ---------------------------- | ------------- | ------------------------------------------------------ |
| CookieSigningSalt | `COOKIE_SIGNING_SALT` | *(none)* | Salt for signing and securing cookies used in sessions |
| PublicURL | `PUBLIC_URL` | *(none)* | Public URL for auth callbacks from OAuth providers |
| PublicURL | `PUBLIC_URL` | *(none)* | Public base URL used to build OAuth callback URLs such as `/auth/login-callback` |
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The callback path referenced here is missing the API base path. In backend/pkg/server/router.go, the redirect URI is built with path.Join(baseURL, "/auth/login-callback") where baseURL is /api/v1, so the provider redirect URI becomes ${PUBLIC_URL}/api/v1/auth/login-callback (not ${PUBLIC_URL}/auth/login-callback). Also note the router overwrites publicURL.Path, so PUBLIC_URL should be an origin (scheme/host/port) without an additional path segment.

Copilot uses AI. Check for mistakes.
Comment thread backend/docs/config.md
Comment on lines +420 to +423
In the default deployment, configure your OAuth providers with:
- **Homepage URL**: `PUBLIC_URL`
- **Authorization callback URL / Redirect URI**: `${PUBLIC_URL}/auth/login-callback`

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This section instructs configuring the provider redirect URI as ${PUBLIC_URL}/auth/login-callback, but the actual route registered by the router is under the API group (/api/v1/auth/login-callback). Please update the provider configuration bullets and example to match the real redirect URI to avoid continued redirect_uri mismatch errors.

Copilot uses AI. Check for mistakes.
Comment thread README.md Outdated
Comment on lines +2334 to +2338
PentAGI uses `PUBLIC_URL` as the public base URL for OAuth redirects. In the default deployment, both GitHub and Google callbacks are handled by:

For using Google OAuth you need to create a new OAuth application in your Google account and set the `OAUTH_GOOGLE_CLIENT_ID` and `OAUTH_GOOGLE_CLIENT_SECRET` in `.env` file.
```text
${PUBLIC_URL}/auth/login-callback
```
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The documented callback endpoint ${PUBLIC_URL}/auth/login-callback does not match the server route. In backend/pkg/server/router.go, the callback is registered under the /api/v1 group, so the actual redirect URI is ${PUBLIC_URL}/api/v1/auth/login-callback. Please update this block accordingly so users don’t configure the wrong redirect URI.

Copilot uses AI. Check for mistakes.
Comment thread README.md Outdated

1. Create a new OAuth App in your GitHub account.
2. Set **Homepage URL** to your `PUBLIC_URL`.
3. Set **Authorization callback URL** to `${PUBLIC_URL}/auth/login-callback`.
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

These GitHub OAuth setup steps use ${PUBLIC_URL}/auth/login-callback, but the backend registers the callback under /api/v1/auth/login-callback. Please update the Authorization callback URL value to ${PUBLIC_URL}/api/v1/auth/login-callback to align with the actual redirect URI sent by PentAGI.

Suggested change
3. Set **Authorization callback URL** to `${PUBLIC_URL}/auth/login-callback`.
3. Set **Authorization callback URL** to `${PUBLIC_URL}/api/v1/auth/login-callback`.

Copilot uses AI. Check for mistakes.
Comment thread README.md
Comment on lines +2355 to +2357
1. Create OAuth credentials in your Google Cloud project.
2. Use the same callback endpoint: `${PUBLIC_URL}/auth/login-callback`.
3. Add the client credentials to your `.env` file:
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

Similarly for Google OAuth, the redirect URI should include the API base path. The backend callback endpoint is ${PUBLIC_URL}/api/v1/auth/login-callback, not ${PUBLIC_URL}/auth/login-callback; otherwise Google will reject the login with a redirect URI mismatch.

Copilot uses AI. Check for mistakes.
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.

[Enhancement]: Github OAuth应用程序集成问题

3 participants