github / github/copilot-cli

Copilot CLI OAuth login fails — CLI doesn't bind to port declared in its own CIMD client-metadata.json

Open
#4,800 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
Shell
Stars
11.2k
Forks
1.9k
Avg merge
14h 16m
Merged PRs (30d)
6

Description

Describe the bug

When authenticating to an MCP server that uses CIMD (Client ID Metadata Document) OAuth, Copilot CLI fails with:

{"error":"invalid_request","error_description":"Redirect URI 'http://127.0.0.1:<random_port>/' does not match CIMD redirect_uris.","state":"..."}

Root cause: Copilot CLI's own published client metadata ( https://github.com/copilot/cli/client-metadata.json ) declares a single fixed redirect URI:

"redirect_uris": ["http://127.0.0.1:33418/"]

Per the CIMD/OAuth spec, the redirect_uri used in the  /authorize  request must exactly match this declared value (RFC 8252's "any loopback port" leniency only applies when no port is specified — here one is).

However, Copilot CLI does not bind its local OAuth callback listener to port 33418 — it uses a different, seemingly random port instead (observed: 63450, then 61566), even when port 33418 is confirmed free/unused on the machine. This causes every login attempt against CIMD-based OAuth servers to fail.

Affected version

Copilot CLI v1.0.83, Windows

Steps to reproduce the behavior
  1. Confirm port 33418 is free ( Get-NetTCPConnection -LocalPort 33418  returns nothing).
  2. Attempt login to an MCP server using CIMD OAuth (client_id = a metadata document URL).
  3. Copilot CLI opens a callback listener on a different port than 33418.
  4. Server rejects with  invalid_request  / redirect_uri mismatch.
Expected behavior

Copilot CLI should bind its OAuth loopback listener to the exact port(s) declared in its own  client-metadata.json  (33418), consistent with CIMD requirements.

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the OAuth flow from the /authorize request to the local loopback callback listener, then compare its selected port with the redirect_uris value in the published client-metadata.json. Reproduce with port 33418 free and a CIMD MCP server; done means the listener and request use the declared URI and login no longer returns invalid_request.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
authentication, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.