|
7 | 7 | "strings" |
8 | 8 | "time" |
9 | 9 |
|
| 10 | + "github.com/github/github-mcp-server/internal/buildinfo" |
10 | 11 | "github.com/github/github-mcp-server/internal/ghmcp" |
11 | 12 | "github.com/github/github-mcp-server/internal/oauth" |
12 | 13 | "github.com/github/github-mcp-server/pkg/github" |
|
37 | 38 | RunE: func(_ *cobra.Command, _ []string) error { |
38 | 39 | token := viper.GetString("personal_access_token") |
39 | 40 | oauthClientID := viper.GetString("oauth-client-id") |
| 41 | + oauthClientSecret := viper.GetString("oauth-client-secret") |
| 42 | + // Fall back to the build-time baked-in client (official releases) when none is |
| 43 | + // configured explicitly. The baked-in app is registered on github.com, so it is |
| 44 | + // only applied to the default host; GHES/ghe.com users must bring their own |
| 45 | + // --oauth-client-id. The secret tracks the id, so an explicitly provided id with |
| 46 | + // no secret never picks up the baked-in secret. |
| 47 | + if oauthClientID == "" && viper.GetString("host") == "" { |
| 48 | + oauthClientID = buildinfo.OAuthClientID |
| 49 | + oauthClientSecret = buildinfo.OAuthClientSecret |
| 50 | + } |
40 | 51 | if token == "" && oauthClientID == "" { |
41 | 52 | return errors.New("authentication required: set GITHUB_PERSONAL_ACCESS_TOKEN, or pass --oauth-client-id to log in via OAuth") |
42 | 53 | } |
@@ -112,7 +123,7 @@ var ( |
112 | 123 | } |
113 | 124 | oauthConfig := oauth.NewGitHubConfig( |
114 | 125 | oauthClientID, |
115 | | - viper.GetString("oauth-client-secret"), |
| 126 | + oauthClientSecret, |
116 | 127 | scopes, |
117 | 128 | viper.GetString("host"), |
118 | 129 | viper.GetInt("oauth-callback-port"), |
|
0 commit comments