mcpauth: an MCP server's own OAuth app is called back at Claude Code's http://localhost:<port>/callback, so an app made for Claude Code signs magpie in as it is (新v学员 on Discord)
What changed: accc8c090 took Claude Code's names for a server's own
OAuth app (oauth.clientId, clientSecret, callbackPort) but sent
redirect_uri=http://127.0.0.1:<port>/callback. Claude Code sends
http://localhost:<port>/callback:
- code.claude.com/docs/en/mcp, "Use pre-configured OAuth credentials":
register http://localhost:PORT/callback; --callback-port fixes the
port to match it. Its version note says 2.1.229 sent 127.0.0.1 and
servers that match the registered URL exactly refused the sign-in,
so 2.1.231 went back to localhost.
- The installed Claude Code 2.1.296 binary builds
`http://localhost:${n}/callback` (default port 3118 / a random
free one, MCP_OAUTH_CALLBACK_PORT) and listens on 127.0.0.1 only.
So an app registered for Claude Code at an exact-match server was
refused by magpie. StartWith now sends localhost for a user's own app
and still listens on 127.0.0.1 alone, as Claude Code does, so the hosts
don't differ and the editor needs no note. magpie's own dynamic
registration keeps 127.0.0.1 (it registers that URL itself).
The no-registration error, the editor's hint (now
http://localhost[:port]/callback), its zh/zh-TW/ja/de translations,
the OAuthApp comment and docs/subsystems/library.md say localhost.
Run:
- New TestAppMadeForClaudeCode: the GitHub-shaped fake matching one
exact registered URL http://localhost:<port>/callback, at authorize
and at the token request. With the old mcpauth.go it fails (as do
the three GitHub tests now asserting localhost); with the fix all
pass. go test -race ./internal/mcpauth/...
- go test -tags nogui ./internal/library ./internal/gui
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
- GUI mcp-oauth-app (Chromium+WebKit, 1100/390, en zh zh-TW ja de,
22/22) and i18n-keys; with the hint's old 127.0.0.1 put back by hand,
mcp-oauth-app goes red (0/11 Chromium).
Not run: a real sign-in with a real OAuth app (none to use). GitHub's
docs say a loopback redirect needn't match the registered port but
don't say whether that holds for localhost as it does for 127.0.0.1;
if GitHub wants the port, the user sets Callback port and registers
http://localhost:<port>/callback, as Claude Code's docs also say.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1774,7 +1774,7 @@ const I18N = {
|
||||
"Client secret": "客户端密钥",
|
||||
"Callback port": "回调端口",
|
||||
"Made with its vendor (GitHub's under Settings › Developer settings › OAuth Apps), with {url} as its callback URL": "在服务方创建(GitHub 的在 Settings › Developer settings › OAuth Apps),回调 URL 填 {url}",
|
||||
"the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://127.0.0.1/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor": "该服务器的登录不允许应用自行注册(不支持动态客户端注册),因此 magpie 只能以你自己的 OAuth 应用登录:在服务方创建一个(GitHub 的在 Settings › Developer settings › OAuth Apps),回调 URL 填 http://127.0.0.1/callback,再在该服务器编辑器的「OAuth 应用」中填入它的客户端 ID 和密钥",
|
||||
"the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://localhost/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor": "该服务器的登录不允许应用自行注册(不支持动态客户端注册),因此 magpie 只能以你自己的 OAuth 应用登录:在服务方创建一个(GitHub 的在 Settings › Developer settings › OAuth Apps),回调 URL 填 http://localhost/callback,再在该服务器编辑器的「OAuth 应用」中填入它的客户端 ID 和密钥",
|
||||
"Sign-in required": "需要重新登录",
|
||||
"GitHub refused this Copilot sign-in; sign in again": "GitHub 拒绝了这个 Copilot 登录,请重新登录",
|
||||
"The vendor revoked this sign-in; sign in again": "服务商已撤销这个登录,请重新登录",
|
||||
@@ -6259,7 +6259,7 @@ const I18N = {
|
||||
"Client secret": "用戶端密鑰",
|
||||
"Callback port": "回呼連接埠",
|
||||
"Made with its vendor (GitHub's under Settings › Developer settings › OAuth Apps), with {url} as its callback URL": "在服務方建立(GitHub 的在 Settings › Developer settings › OAuth Apps),回呼 URL 填 {url}",
|
||||
"the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://127.0.0.1/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor": "該伺服器的登入不允許應用程式自行註冊(不支援動態用戶端註冊),因此 magpie 只能以你自己的 OAuth 應用程式登入:在服務方建立一個(GitHub 的在 Settings › Developer settings › OAuth Apps),回呼 URL 填 http://127.0.0.1/callback,再在該伺服器編輯器的「OAuth 應用程式」中填入它的用戶端 ID 和密鑰",
|
||||
"the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://localhost/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor": "該伺服器的登入不允許應用程式自行註冊(不支援動態用戶端註冊),因此 magpie 只能以你自己的 OAuth 應用程式登入:在服務方建立一個(GitHub 的在 Settings › Developer settings › OAuth Apps),回呼 URL 填 http://localhost/callback,再在該伺服器編輯器的「OAuth 應用程式」中填入它的用戶端 ID 和密鑰",
|
||||
"Sign-in required": "需要重新登入",
|
||||
"GitHub refused this Copilot sign-in; sign in again": "GitHub 拒絕了這個 Copilot 登入,請重新登入",
|
||||
"The vendor revoked this sign-in; sign in again": "服務商已撤銷這個登入,請重新登入",
|
||||
@@ -10720,7 +10720,7 @@ const I18N = {
|
||||
"Client secret": "クライアントシークレット",
|
||||
"Callback port": "コールバックポート",
|
||||
"Made with its vendor (GitHub's under Settings › Developer settings › OAuth Apps), with {url} as its callback URL": "提供元で作成し(GitHub は Settings › Developer settings › OAuth Apps)、コールバック URL に {url} を指定します",
|
||||
"the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://127.0.0.1/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor": "このサーバーのサインインはアプリの自己登録(動的クライアント登録)を受け付けないため、magpie は自分で用意した OAuth アプリとしてのみサインインできます。提供元でアプリを作成し(GitHub は Settings › Developer settings › OAuth Apps)、コールバック URL に http://127.0.0.1/callback を指定してから、サーバーの編集画面の「OAuth アプリ」にクライアント ID とシークレットを入力してください",
|
||||
"the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://localhost/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor": "このサーバーのサインインはアプリの自己登録(動的クライアント登録)を受け付けないため、magpie は自分で用意した OAuth アプリとしてのみサインインできます。提供元でアプリを作成し(GitHub は Settings › Developer settings › OAuth Apps)、コールバック URL に http://localhost/callback を指定してから、サーバーの編集画面の「OAuth アプリ」にクライアント ID とシークレットを入力してください",
|
||||
"Sign-in required": "サインインが必要です",
|
||||
"GitHub refused this Copilot sign-in; sign in again": "GitHub がこの Copilot のサインインを拒否しました。再度サインインしてください",
|
||||
"The vendor revoked this sign-in; sign in again": "ベンダーがこのサインインを取り消しました。再度サインインしてください",
|
||||
@@ -15200,7 +15200,7 @@ const I18N = {
|
||||
"Client secret": "Client-Secret",
|
||||
"Callback port": "Callback-Port",
|
||||
"Made with its vendor (GitHub's under Settings › Developer settings › OAuth Apps), with {url} as its callback URL": "Beim Anbieter angelegt (bei GitHub unter Settings › Developer settings › OAuth Apps), mit {url} als Callback-URL",
|
||||
"the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://127.0.0.1/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor": "die Anmeldung dieses Servers lässt keine App sich selbst registrieren (keine dynamische Client-Registrierung), daher meldet sich magpie nur als eigene OAuth-App an: Lege beim Anbieter eine an (bei GitHub unter Settings › Developer settings › OAuth Apps) mit http://127.0.0.1/callback als Callback-URL und trage ihre Client-ID und ihr Secret unter „OAuth-App“ im Editor des Servers ein",
|
||||
"the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://localhost/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor": "die Anmeldung dieses Servers lässt keine App sich selbst registrieren (keine dynamische Client-Registrierung), daher meldet sich magpie nur als eigene OAuth-App an: Lege beim Anbieter eine an (bei GitHub unter Settings › Developer settings › OAuth Apps) mit http://localhost/callback als Callback-URL und trage ihre Client-ID und ihr Secret unter „OAuth-App“ im Editor des Servers ein",
|
||||
"Sign-in required": "Anmeldung erforderlich",
|
||||
"GitHub refused this Copilot sign-in; sign in again": "GitHub hat diese Copilot-Anmeldung abgelehnt; bitte erneut anmelden",
|
||||
"The vendor revoked this sign-in; sign in again": "Der Anbieter hat diese Anmeldung widerrufen; bitte erneut anmelden",
|
||||
|
||||
@@ -1889,7 +1889,7 @@
|
||||
appBox.append(id, secret, port, x);
|
||||
if (hint) hint.textContent = callback();
|
||||
}
|
||||
const callback = () => t("Made with its vendor (GitHub's under Settings › Developer settings › OAuth Apps), with {url} as its callback URL", { url: "http://127.0.0.1" + (d.oauth?.callbackPort ? ":" + d.oauth.callbackPort : "") + "/callback" });
|
||||
const callback = () => t("Made with its vendor (GitHub's under Settings › Developer settings › OAuth Apps), with {url} as its callback URL", { url: "http://localhost" + (d.oauth?.callbackPort ? ":" + d.oauth.callbackPort : "") + "/callback" });
|
||||
const name = field2(d.name, t("e.g. github"), (v) => { d.name = v.trim(); signBox?.redraw(); });
|
||||
ed.append(...field(t("Name"), name, t("Letters, digits, - and _ — what the agents call it")));
|
||||
const kindOf = () => segs([["stdio", t("Command")], ["http", "HTTP"], ["sse", "SSE"]], d.transport, (v) => { d.transport = v; draw(); });
|
||||
|
||||
@@ -23,7 +23,7 @@ const agent = (id, name) => ({ id, name, icon: "", skills: `${HOME}/.${id}/skill
|
||||
const GH = "https://api.githubcopilot.com/mcp/";
|
||||
const ID = "Ov23liAbCdEfGhIjKlMn", SECRET = "0123456789abcdef0123456789abcdef01234567";
|
||||
// mcpauth.ErrNoRegistration, as the backend says it
|
||||
const NO_REG = "the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://127.0.0.1/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor";
|
||||
const NO_REG = "the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://localhost/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor";
|
||||
|
||||
function server(lang, calls) {
|
||||
const lib = {
|
||||
@@ -113,7 +113,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await box.locator(".lib-signin-err", { hasText: w(NO_REG) }).waitFor();
|
||||
await input("Client ID").waitFor();
|
||||
assert.equal(await page.evaluate(() => document.activeElement?.getAttribute("aria-label")), w("Client ID"));
|
||||
await hint("http://127.0.0.1/callback").waitFor();
|
||||
await hint("http://localhost/callback").waitFor();
|
||||
|
||||
// typed but not saved: Cancel asks, and nothing is saved
|
||||
await input("Client ID").fill(ID);
|
||||
@@ -129,7 +129,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await input("Client secret").getAttribute("type"), "password");
|
||||
await input("Callback port").pressSequentially("31a18");
|
||||
assert.equal(await input("Callback port").inputValue(), "3118");
|
||||
await hint("http://127.0.0.1:3118/callback").waitFor();
|
||||
await hint("http://localhost:3118/callback").waitFor();
|
||||
await box.getByRole("button", { name: w("Save and sign in"), exact: true }).click();
|
||||
await box.getByRole("button", { name: w("Cancel"), exact: true }).click();
|
||||
await box.getByRole("button", { name: w("Sign in"), exact: true }).waitFor();
|
||||
|
||||
@@ -55,7 +55,7 @@ type OAuthApp struct {
|
||||
ClientID string `json:"clientId"`
|
||||
ClientSecret string `json:"clientSecret,omitempty"`
|
||||
// CallbackPort is the port of the callback URL the app was made with;
|
||||
// 0 for one made with http://127.0.0.1/callback, which takes any
|
||||
// 0 for one made with http://localhost/callback, which takes any
|
||||
CallbackPort int `json:"callbackPort,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ type gitHub struct {
|
||||
|
||||
id, secret string // the user's OAuth app
|
||||
refresh bool // tokens that run out, with a refresh token (a GitHub App's)
|
||||
// exact is the app's one callback URL when the server matches it
|
||||
// exactly, port and host too, as many do; empty, a loopback callback
|
||||
// takes any port, as GitHub's does
|
||||
exact string
|
||||
|
||||
mu sync.Mutex
|
||||
codes map[string]string // code → its PKCE challenge
|
||||
@@ -72,9 +76,13 @@ func newGitHub(t *testing.T, id, secret string) *gitHub {
|
||||
mux.HandleFunc("/login/oauth/authorize", func(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
back, err := url.Parse(q.Get("redirect_uri"))
|
||||
// a loopback callback URL registered as http://127.0.0.1/callback
|
||||
// takes any port
|
||||
if q.Get("client_id") != g.id || err != nil || back.Hostname() != "127.0.0.1" || back.Path != "/callback" || q.Get("code_challenge_method") != "S256" {
|
||||
// a loopback callback URL registered as http://localhost/callback
|
||||
// takes any port; an exact one takes only itself
|
||||
loopback := err == nil && (back.Hostname() == "localhost" || back.Hostname() == "127.0.0.1") && back.Path == "/callback"
|
||||
if g.exact != "" {
|
||||
loopback = q.Get("redirect_uri") == g.exact
|
||||
}
|
||||
if q.Get("client_id") != g.id || !loopback || q.Get("code_challenge_method") != "S256" {
|
||||
http.Error(w, "The redirect_uri is not associated with this application.", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
@@ -114,7 +122,7 @@ func newGitHub(t *testing.T, id, secret string) *gitHub {
|
||||
challenge, ok := g.codes[r.PostForm.Get("code")]
|
||||
delete(g.codes, r.PostForm.Get("code"))
|
||||
sum := sha256.Sum256([]byte(r.PostForm.Get("code_verifier")))
|
||||
if !ok || base64.RawURLEncoding.EncodeToString(sum[:]) != challenge {
|
||||
if !ok || base64.RawURLEncoding.EncodeToString(sum[:]) != challenge || (g.exact != "" && r.PostForm.Get("redirect_uri") != g.exact) {
|
||||
io.WriteString(w, `{"error":"bad_verification_code","error_description":"The code passed is incorrect or expired.","error_uri":"https://docs.github.com/apps/managing-oauth-apps/troubleshooting-oauth-app-access-token-request-errors/#bad-verification-code"}`)
|
||||
return
|
||||
}
|
||||
@@ -170,7 +178,7 @@ func TestGitHubWithoutAnApp(t *testing.T) {
|
||||
if !errors.Is(err, mcpauth.ErrNoRegistration) {
|
||||
t.Fatalf("err = %v", err)
|
||||
}
|
||||
for _, s := range []string{"OAuth app of your own", "http://127.0.0.1/callback", "client ID"} {
|
||||
for _, s := range []string{"OAuth app of your own", "http://localhost/callback", "client ID"} {
|
||||
if !strings.Contains(err.Error(), s) {
|
||||
t.Errorf("the error doesn't say %q: %v", s, err)
|
||||
}
|
||||
@@ -178,7 +186,7 @@ func TestGitHubWithoutAnApp(t *testing.T) {
|
||||
}
|
||||
|
||||
// With the user's app, magpie registers nothing: it signs in as that app,
|
||||
// called back at 127.0.0.1's /callback, and gives the secret in the form,
|
||||
// called back at localhost's /callback as Claude Code is, and gives the secret in the form,
|
||||
// as GitHub's token endpoint takes it. The record keeps the app, to renew
|
||||
// as it.
|
||||
func TestGitHubSignInAsTheUsersApp(t *testing.T) {
|
||||
@@ -199,7 +207,7 @@ func TestGitHubSignInAsTheUsersApp(t *testing.T) {
|
||||
if f.Get("client_id") != id || f.Get("client_secret") != secret || f.Get("grant_type") != "authorization_code" {
|
||||
t.Errorf("token request = %v", f)
|
||||
}
|
||||
if u, _ := url.Parse(g.redirect()); u.Hostname() != "127.0.0.1" || u.Path != "/callback" || u.Port() == "" {
|
||||
if u, _ := url.Parse(g.redirect()); u.Hostname() != "localhost" || u.Path != "/callback" || u.Port() == "" {
|
||||
t.Errorf("redirect_uri = %s", g.redirect())
|
||||
}
|
||||
}
|
||||
@@ -238,11 +246,37 @@ func TestGitHubCallbackPort(t *testing.T) {
|
||||
if st := signInAs(t, "github", g.URL, &mcpauth.App{ClientID: id, ClientSecret: secret, CallbackPort: port}); st.State != "done" {
|
||||
t.Fatalf("sign-in %s: %s", st.State, st.Error)
|
||||
}
|
||||
if want := fmt.Sprintf("http://127.0.0.1:%d/callback", port); g.redirect() != want {
|
||||
if want := fmt.Sprintf("http://localhost:%d/callback", port); g.redirect() != want {
|
||||
t.Errorf("redirect_uri = %s, want %s", g.redirect(), want)
|
||||
}
|
||||
}
|
||||
|
||||
// An app made for Claude Code signs magpie in as it is. Claude Code calls
|
||||
// a pre-configured client back at http://localhost:<callbackPort>/callback
|
||||
// (code.claude.com/docs/en/mcp, "Use pre-configured OAuth credentials";
|
||||
// its 2.1.296 builds it as `http://localhost:${port}/callback` and listens
|
||||
// on 127.0.0.1), and a server that matches the registered URL exactly
|
||||
// refuses any other host: Claude Code's own 2.1.229 sent 127.0.0.1 and was
|
||||
// refused, until 2.1.231 went back to localhost.
|
||||
func TestAppMadeForClaudeCode(t *testing.T) {
|
||||
home(t)
|
||||
id, secret := "Ov23liAbCdEfGhIjKlMn", "0123456789abcdef0123456789abcdef01234567"
|
||||
g := newGitHub(t, id, secret)
|
||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
port := ln.Addr().(*net.TCPAddr).Port
|
||||
ln.Close()
|
||||
g.exact = fmt.Sprintf("http://localhost:%d/callback", port)
|
||||
if st := signInAs(t, "github", g.URL, &mcpauth.App{ClientID: id, ClientSecret: secret, CallbackPort: port}); st.State != "done" {
|
||||
t.Fatalf("sign-in %s: %s (registered %s)", st.State, st.Error, g.exact)
|
||||
}
|
||||
if f := g.lastForm(); f.Get("redirect_uri") != g.exact {
|
||||
t.Errorf("token request's redirect_uri = %s", f.Get("redirect_uri"))
|
||||
}
|
||||
}
|
||||
|
||||
// A refresh token GitHub won't take again (its 200 bad_refresh_token) runs
|
||||
// the sign-in out, as invalid_grant does elsewhere.
|
||||
func TestGitHubBadRefreshToken(t *testing.T) {
|
||||
|
||||
@@ -88,7 +88,7 @@ var ErrClientRefused = errors.New("this server's sign-in admits only the apps it
|
||||
// OAuth app of the user's own, made with the server's vendor, as Claude
|
||||
// Code does with --client-id. The page opens the server's fields for one
|
||||
// on it.
|
||||
var ErrNoRegistration = errors.New("the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://127.0.0.1/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor")
|
||||
var ErrNoRegistration = errors.New("the server's sign-in doesn't let an app register itself (no dynamic client registration), so magpie signs in to it only as an OAuth app of your own: make one with the server's vendor (GitHub's under Settings › Developer settings › OAuth Apps), with http://localhost/callback as its callback URL, then give its client ID and secret under \"OAuth app\" in the server's editor")
|
||||
|
||||
// Record is magpie's sign-in to one server.
|
||||
type Record struct {
|
||||
@@ -778,9 +778,12 @@ func randomToken(n int) string {
|
||||
|
||||
// App is an OAuth app of the user's own, for a server whose sign-in
|
||||
// doesn't let magpie register itself: Claude Code's --client-id,
|
||||
// --client-secret and --callback-port. Without a CallbackPort the
|
||||
// callback comes to any free port of 127.0.0.1, which a loopback callback
|
||||
// URL registered without one takes (GitHub's, RFC 8252).
|
||||
// --client-secret and --callback-port. Its callback is Claude Code's,
|
||||
// http://localhost:<port>/callback, so an app made for Claude Code signs
|
||||
// magpie in as it is; the callback is still listened for on 127.0.0.1
|
||||
// alone, as Claude Code does. Without a CallbackPort the port is any free
|
||||
// one, which a loopback callback URL registered without one takes
|
||||
// (GitHub's, RFC 8252).
|
||||
type App struct {
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
@@ -814,7 +817,15 @@ func StartWith(ctx context.Context, name, serverURL string, app *App) (State, er
|
||||
}
|
||||
return State{}, err
|
||||
}
|
||||
redirect := fmt.Sprintf("http://127.0.0.1:%d/callback", ln.Addr().(*net.TCPAddr).Port)
|
||||
// magpie's own registration names 127.0.0.1, as RFC 8252 asks; an
|
||||
// app of the user's own is called back as Claude Code calls it back,
|
||||
// at localhost (its v2.1.231 went back to localhost because servers
|
||||
// that match the registered URL exactly refused 127.0.0.1).
|
||||
host := "127.0.0.1"
|
||||
if app != nil {
|
||||
host = "localhost"
|
||||
}
|
||||
redirect := fmt.Sprintf("http://%s:%d/callback", host, ln.Addr().(*net.TCPAddr).Port)
|
||||
var id, secret, method string
|
||||
if app != nil {
|
||||
id, secret, method = app.ClientID, app.ClientSecret, appMethod(m, app.ClientSecret)
|
||||
|
||||
Reference in New Issue
Block a user