Skip to content

Commit 5240bcb

Browse files
fix: Restore hardcoded OAuth credentials following llxprt-code pattern
Following the OAuth 2.0 installed application pattern used by llxprt-code. These public client credentials are meant to be embedded in source code per Google's documentation. Reference: https://developers.google.com/identity/protocols/oauth2#installed
1 parent f906938 commit 5240bcb

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

internal/oauth/defaults.go

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
package oauth
22

3-
import "os"
4-
53
// DefaultOAuthConfig holds preconfigured OAuth credentials for providers
6-
// These credentials should be configured via environment variables or config file
7-
// following the OAuth 2.0 "installed application" pattern.
4+
// These credentials are embedded in the application following the OAuth 2.0
5+
// "installed application" pattern, as described in Google's OAuth documentation:
6+
// https://developers.google.com/identity/protocols/oauth2#installed
87
//
9-
// For desktop/CLI applications:
8+
// For desktop/CLI applications, it's acceptable to embed OAuth client credentials
9+
// in the source code because:
1010
// 1. Users authenticate with their own accounts (get their own tokens)
1111
// 2. PKCE (Proof Key for Code Exchange) protects against authorization code interception
1212
// 3. Client secrets are not treated as secret for public clients
1313
//
14+
// Note: It's ok to save this in git because this is an installed application
15+
// as described here: https://developers.google.com/identity/protocols/oauth2#installed
16+
// "The process results in a client ID and, in some cases, a client secret,
17+
// which you embed in the source code of your application. (In this context,
18+
// the client secret is obviously not treated as a secret.)"
19+
//
1420
// To register OAuth apps and get credentials:
1521
// - Anthropic: https://console.anthropic.com/settings/oauth
1622
// - Gemini: https://console.cloud.google.com/apis/credentials
1723
// - Qwen: https://dashscope.console.aliyun.com/
18-
//
19-
// Environment variables:
20-
// - ANTHROPIC_OAUTH_CLIENT_ID
21-
// - GEMINI_OAUTH_CLIENT_ID and GEMINI_OAUTH_CLIENT_SECRET
22-
// - QWEN_OAUTH_CLIENT_ID
2324

2425
type OAuthProviderConfig struct {
2526
ClientID string
@@ -32,23 +33,26 @@ type OAuthProviderConfig struct {
3233

3334
var (
3435
// AnthropicOAuth holds Anthropic Claude OAuth configuration
35-
// Set ANTHROPIC_OAUTH_CLIENT_ID environment variable
36+
// Uses the official Claude Code CLI OAuth client ID
3637
// This is a public client (PKCE-protected, no client secret)
38+
// Source: https://github.com/anthropics/claude-code
3739
AnthropicOAuth = OAuthProviderConfig{
38-
ClientID: os.Getenv("ANTHROPIC_OAUTH_CLIENT_ID"),
39-
ClientSecret: "",
40+
ClientID: "9d1c250a-e61b-44d9-88ed-5944d1962f5e", // Official Claude Code CLI client ID
41+
ClientSecret: "", // Anthropic uses PKCE, no client secret needed
4042
AuthURL: "https://claude.ai/oauth/authorize",
4143
TokenURL: "https://console.anthropic.com/v1/oauth/token",
4244
RefreshURL: "https://console.anthropic.com/v1/oauth/token",
4345
Scopes: []string{"org:create_api_key", "user:profile", "user:inference"},
4446
}
4547

4648
// GeminiOAuth holds Google Gemini OAuth configuration
47-
// Set GEMINI_OAUTH_CLIENT_ID and GEMINI_OAUTH_CLIENT_SECRET environment variables
49+
// Uses the official Gemini CLI OAuth client ID
4850
// This is a public client as per Google's OAuth 2.0 "installed application" pattern
51+
// Source: https://github.com/google-gemini/gemini-cli (llxprt-code)
52+
// Note: Client secret is public for desktop apps (see https://developers.google.com/identity/protocols/oauth2#installed)
4953
GeminiOAuth = OAuthProviderConfig{
50-
ClientID: os.Getenv("GEMINI_OAUTH_CLIENT_ID"),
51-
ClientSecret: os.Getenv("GEMINI_OAUTH_CLIENT_SECRET"),
54+
ClientID: "681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com", // Official Gemini CLI client ID
55+
ClientSecret: "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", // Public client secret (from llxprt-code)
5256
AuthURL: "https://accounts.google.com/o/oauth2/v2/auth",
5357
TokenURL: "https://oauth2.googleapis.com/token",
5458
RefreshURL: "https://oauth2.googleapis.com/token",
@@ -60,11 +64,12 @@ var (
6064
}
6165

6266
// QwenOAuth holds Alibaba Qwen OAuth configuration
63-
// Set QWEN_OAUTH_CLIENT_ID environment variable
67+
// Uses the client ID from Qwen Code implementation
6468
// This is a public client for device flow authentication
69+
// Source: Qwen Code documentation
6570
QwenOAuth = OAuthProviderConfig{
66-
ClientID: os.Getenv("QWEN_OAUTH_CLIENT_ID"),
67-
ClientSecret: "",
71+
ClientID: "f0304373b74a44d2b584a3fb70ca9e56", // Qwen Code client ID
72+
ClientSecret: "", // Qwen uses device flow, no client secret needed
6873
AuthURL: "https://chat.qwen.ai/api/v1/oauth2/device/code",
6974
TokenURL: "https://chat.qwen.ai/api/v1/oauth2/token",
7075
RefreshURL: "https://chat.qwen.ai/api/v1/oauth2/token",

0 commit comments

Comments
 (0)