Skip to content

[MCP] Fix the bearer token authorization header#4846

Merged
gpeal merged 2 commits intomainfrom
gpeal/github-auth-debugging
Oct 6, 2025
Merged

[MCP] Fix the bearer token authorization header#4846
gpeal merged 2 commits intomainfrom
gpeal/github-auth-debugging

Conversation

@gpeal
Copy link
Copy Markdown
Collaborator

@gpeal gpeal commented Oct 6, 2025

http_config.auth_header automatically added Bearer . By adding it ourselves, we were sending Bearer Bearer <token>.

I confirmed that the GitHub MCP initialization 400s before and works now.

I also optimized the oauth flow to not check the keyring if you explicitly pass in a bearer token.

@gpeal gpeal requested a review from bolinfest October 6, 2025 21:09
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines 140 to +143
} else {
let mut http_config = StreamableHttpClientTransportConfig::with_uri(url.to_string());
if let Some(bearer_token) = bearer_token {
http_config = http_config.auth_header(format!("Bearer {bearer_token}"));
http_config = http_config.auth_header(bearer_token);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P0 Badge Don’t move bearer_token before building HTTP config

In new_streamable_http_client the initial OAuth tokens are computed with match bearer_token { … } and later the same bearer_token is matched again to populate the auth header. Because Option<String> is not Copy, the first match moves bearer_token and the later if let Some(bearer_token) = bearer_token cannot compile (value used after move). This commit therefore fails to build. Consider matching on a reference (bearer_token.as_ref()) or cloning before the first match.

Useful? React with 👍 / 👎.

@gpeal gpeal merged commit d73055c into main Oct 6, 2025
20 checks passed
@gpeal gpeal deleted the gpeal/github-auth-debugging branch October 6, 2025 21:41
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants