anthropics / anthropics/claude-code

[BUG] Google Sheets connector OAuth fails from CLI (product_surface=cli) but works on Desktop app

未关闭
#89,744 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area:auth area:cli area:mcp bug platform:macos
主要语言
Python
星标
145k
派生
23.1k
PR 合并指标
PR 指标待抓取

描述

### Preflight Checklist

- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code

### What's Wrong?

When connecting the Google Sheets MCP connector from Claude Code CLI (`claude`) running inside a terminal, the browser opens the Google OAuth authorize URL, but instead of the normal Google consent screen, it lands on Google's generic Sheets error page: "Sorry, unable to open the file at present. Please check the address and try again."

The failing URL is of the form:
https://sheets.googleapis.com/authorize?response_type=code&client_id=...apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fclaude.ai%2Fapi%2F...

The auth-start link printed by the CLI itself is of the form:
https://claude.ai/api/organizations//mcp/start-auth/mcpsrv_?product_surface=cli

The same "Google Sheets" connector (same connector/org, same Google account) works correctly when connected from the Claude Desktop app - the OAuth flow completes normally and the connector authenticates without issue. Only the CLI-specific auth flow (product_surface=cli) reproduces this failure.

### What Should Happen?

Clicking the auth link (or manually pasting it into an already-logged-in browser) should take the user to Google's normal OAuth consent screen for the Google Sheets scope, complete the grant, and return control to the CLI so it can proceed (same behavior as the Desktop app).

### Error Messages/Logs

```shell
Google's page text: "Sorry, unable to open the file at present. Please check the address and try again."

Displayed URL at time of error (address bar, truncated by browser):
sheets.googleapis.com/authorize?response_type=code&client_id=509117084509-e8fp2nruj94i8hsvuqcv3ge4jv5aua85.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fclaude.ai%2Fapi%2F...
Google's page text: "Sorry, unable to open the file at present. Please check the address and try again."

Displayed URL at time of error (address bar, truncated by browser):
sheets.googleapis.com/authorize?response_type=code&client_id=509117084509-e8fp2nruj94i8hsvuqcv3ge4jv5aua85.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fclaude.ai%2Fapi%2F...

Google's page text: "Sorry, unable to open the file at present. Please check the address and try again."

Displayed URL at time of error (address bar, truncated by browser):
sheets.googleapis.com/authorize?response_type=code&client_id=509117084509-e8fp2nruj94i8hsvuqcv3ge4jv5aua85.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fclaude.ai%2Fapi%2F...

CLI-printed auth-start URL:
https://claude.ai/api/organizations//mcp/start-auth/mcpsrv_01TG6wQMUYbeeuwHip1xx4DS?product_surface=cli
```

### Steps to Reproduce

1. In Claude Code CLI (running in a terminal — reproduced in both VS Code's integrated terminal and a standalone terminal), connect the "Google Sheets" MCP connector.
2. The CLI prints an auth-start URL (https://claude.ai/api/organizations//mcp/start-auth/mcpsrv_?product_surface=cli) and opens it in the default browser.
3. The browser is already logged into the correct Google Workspace account and normally has a working Google session (confirmed: the same account/connector authenticates successfully via the Claude Desktop app).
4. Instead of reaching Google's OAuth consent screen, the browser lands on a Google Sheets-branded error page: "Sorry, unable to open the file at present. Please check the address and try again."
5. Also reproduced by manually copying the CLI's printed auth URL and pasting it into an already-authenticated Chrome window (ruling out the CLI auto-opening the wrong browser).
6. The CLI never receives the completed auth callback, so the connector stays unauthenticated.

Not a regression — this is a new connector auth attempt, not something that previously worked and broke.

### Claude Model

None

### Is this a regression?

No, this never worked

### Last Working Version

_No response_

### Claude Code Version

2.1.246 (Claude Code)

### Platform

Anthropic API

### Operating System

macOS

### Terminal/Shell

VS Code integrated terminal

### Additional Information

Also reproduced identically outside VS Code, in a standalone terminal app (Terminal.app/iTerm), so this is not specific to VS Code's integrated terminal — it's the CLI's OAuth broker in general (product_surface=cli).

The same connector works fine when authenticated via the Claude Desktop app (no product_surface=cli in that flow), which is what points to the CLI-specific auth-start/redirect path as the source of the bug rather than anything in the local browser, terminal, or Google account/session.

贡献指南

这个仓库没有索引到贡献指南

调研方向

The payload names no repository files or tests. Start by reproducing the Google Sheets connection from the CLI and tracing the printed /mcp/start-auth/... URL with product_surface=cli, then compare it with the Desktop flow. Done means the normal Google consent screen appears, the redirect completes, and the CLI receives the authenticated connector.

由索引模型根据 Issue 内容生成。

评估

领域
api, authentication, cli
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。