René's URL Explorer Experiment


Title: OAuth client can never recover from an expired DCR client secret — even though the SDK's own server issues and enforces one · Issue #3256 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: OAuth client can never recover from an expired DCR client secret — even though the SDK's own server issues and enforces one · Issue #3256 · modelcontextprotocol/python-sdk

X Title: OAuth client can never recover from an expired DCR client secret — even though the SDK's own server issues and enforces one · Issue #3256 · modelcontextprotocol/python-sdk

Description: Initial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before openi...

Open Graph Description: Initial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/modelcontex...

X Description: Initial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/mod...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3256

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OAuth client can never recover from an expired DCR client secret — even though the SDK's own server issues and enforces one","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1)\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Release line\n\n2.x (current stable) — the code paths below were verified on `main` @ a4f4ccd09113 and are identical on `v1.29.0`; the production observation happened on 1.28.1 (provenance).\n\n### Description\n\n#### Summary\n\nThe SDK ships **both halves of a trap**, and they don't fit together.\n\n**As a server**, the SDK can issue expiring DCR client secrets and rejects them once lapsed:\n\n| step | code (`main` @ a4f4ccd09113) |\n|---|---|\n| knob | `ClientRegistrationOptions.client_secret_expiry_seconds: int \\| None = None` — `src/mcp/server/auth/settings.py:6` |\n| issuance | `client_secret_expires_at = client_id_issued_at + options.client_secret_expiry_seconds` — `src/mcp/server/auth/handlers/register.py:123-129` |\n| enforcement | `if client.client_secret_expires_at and ... \u003c int(time.time()): raise AuthenticationError(\"Client secret has expired\")` — `src/mcp/server/auth/middleware/client_auth.py:116-117` |\n| wire response | `AuthenticationError` → `{\"error\": \"invalid_client\", \"error_description\": \"Client secret has expired\"}` — `src/mcp/server/auth/handlers/token.py:106-113` |\n\n**As a client**, `OAuthClientProvider` persists `client_secret_expires_at` through its own `TokenStorage` abstraction and then never looks at it — and treats `invalid_client` as a plain fatal error:\n\n- Scanning every `.py` file under `src/mcp/client/` (23 files at a4f4ccd09113) finds **zero** occurrences of `client_secret_expires_at` and **zero** of `invalid_client`. Same for `v1.29.0`'s `oauth2.py`.\n- Registration only happens when stored client info is *absent* (`if not self.context.client_info:` in `async_auth_flow`, \"Step 4\"). Expired-but-present client info is reused forever.\n- `_handle_token_response` raises `OAuthTokenError` on any non-200; nothing invalidates the dead registration.\n\n**Consequence**: point an `OAuthClientProvider` at a server that enforces secret expiry — including a server built with this very SDK and `client_secret_expiry_seconds` set — and once the window passes, the client is **permanently stuck**:\n\n1. access token expires → refresh presents the expired `client_secret` → `invalid_client` → SDK falls back to full authorization\n2. full authorization succeeds (the user consents in the browser — the authorization leg is unaffected) → token exchange presents the same expired secret → `invalid_client` again\n3. the next attempt reloads the same client info from storage → registration skipped → back to 1\n\nUser-visible symptom: **\"I re-authenticated and nothing changed.\"** No amount of consent helps. Recovery requires the application to reach into the `TokenStorage` payload and delete the persisted client info by hand — nothing in the API surface hints that a storage payload can become permanently toxic.\n\nExpiring secrets and the absence of a rotation endpoint are both squarely within spec (RFC 7591 makes `client_secret_expires_at` REQUIRED whenever a secret is issued, with `0` meaning \"never expires\"; RFC 7592 is optional and this SDK's server doesn't implement it either — its routes are `/authorize`, `/register`, `/revoke`, `/token` and metadata only). In that world, **re-registration is the only standard recovery path, and the SDK client is the only party that can perform it** — the server can't push a new secret, user consent doesn't touch client authentication, and the application above the SDK doesn't manage `client_info` at all.\n\n#### Real-world occurrence\n\nfreee (a major Japanese accounting SaaS) runs an official remote MCP server at `https://mcp.freee.co.jp/mcp` whose DCR issues secrets that expire 30 days after issuance (observable from its public `/register` endpoint). Our production client (`mcp` 1.28.1) worked for exactly 30 days and then hard-failed exactly as above — with the same error string this SDK's server produces:\n\n```\nPOST /token  (grant_type=refresh_token, expired client credentials)\n→ {\"error\":\"invalid_client\",\"error_description\":\"Client secret has expired\"}\n```\n\nClient authentication is checked before the grant, so *every* token-endpoint interaction dies once the secret lapses (the same registration with live credentials and a deliberately bogus grant returns `invalid_grant` instead — confirming the ordering).\n\n#### Expected behavior\n\nTwo small, complementary changes on the client side:\n\n1. **Treat stored client info with an expired secret as absent.** Before using persisted client info, check `client_secret_expires_at` (non-zero and in the past → discard, fall through to registration / CIMD). `main` already validates freshly returned registrations for usability via `check_registration_usable`; extending that notion to *stored* info seems natural.\n2. **Invalidate stored client info when the server answers `invalid_client`.** Per RFC 6749 §5.2 that means client authentication failed — for a dynamically registered client, the registration is dead by definition. Clearing it (and the tokens bound to it) lets the next flow re-register instead of failing identically forever. Note the HTTP status varies in practice (this SDK's server returns 401, the server we hit returns 400), so keying on the `error` field rather than the status code is the robust form.\n\n(1) fixes the stuck state proactively whenever the AS declares the expiry; (2) also covers servers that expire or revoke registrations without declaring it.\n\nWe currently implement both as an application-side wrapper around `TokenStorage` / the provider, which turned recovery from \"impossible\" into \"one re-consent\" in production.\n\n#### Verification notes\n\n- Code paths above were read at `main` a4f4ccd09113 (2.x) and `v1.29.0` (1.x); the \"zero readers\" claims come from scanning all 23 client files, not a spot check\n- The stuck loop and the `invalid_client` / `invalid_grant` ordering were observed against the third-party server named above\n- **Not verified by us**: an end-to-end SDK-server ↔ SDK-client reproduction (we did not stand up an SDK server with `client_secret_expiry_seconds` set). The claim there rests on the code paths in the table — setting the knob to a few seconds and letting an `OAuthClientProvider` outlive it should confirm it quickly\n\n### Example Code\n\n```python\n# Deterministic client-side reproduction (no 30-day wait): hand the provider a\n# storage that is already in the post-expiry state, then run any flow against a\n# server that enforces expiry (e.g. an SDK server with\n# ClientRegistrationOptions(client_secret_expiry_seconds=\u003csmall>)).\n\nimport time\n\nfrom mcp.client.auth import TokenStorage\nfrom mcp.shared.auth import OAuthClientInformationFull, OAuthToken\n\n\nclass ExpiredClientStorage(TokenStorage):\n    \"\"\"Storage state after the AS-issued client secret lapsed.\"\"\"\n\n    def __init__(self) -> None:\n        self._client_info = OAuthClientInformationFull(\n            client_id=\"registered-client-id\",\n            client_secret=\"expired-secret\",\n            client_secret_expires_at=int(time.time()) - 3600,  # already expired\n            redirect_uris=[\"http://localhost:3030/callback\"],\n            token_endpoint_auth_method=\"client_secret_post\",\n        )\n        self._tokens: OAuthToken | None = None\n\n    async def get_tokens(self) -> OAuthToken | None:\n        return self._tokens\n\n    async def set_tokens(self, tokens: OAuthToken) -> None:\n        self._tokens = tokens\n\n    async def get_client_info(self) -> OAuthClientInformationFull | None:\n        return self._client_info\n\n    async def set_client_info(self, info: OAuthClientInformationFull) -> None:\n        self._client_info = info\n\n\n# Attach to OAuthClientProvider and connect:\n#   - registration is skipped (Step 4 sees client info present),\n#   - authorization succeeds, token exchange fails with invalid_client,\n#   - every subsequent attempt repeats identically — there is no path back.\n```\n\n### Versions\n\n- Observed in production: `mcp` 1.28.1, Python 3.14, streamable HTTP transport\n- Code-inspected as still present: `v1.29.0` (latest 1.x) and `main` @ a4f4ccd09113 (2.x)\n\n✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)\n","author":{"url":"https://github.com/carrotRakko","@type":"Person","name":"carrotRakko"},"datePublished":"2026-08-05T10:54:09Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3256"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b2e45c20-1006-81de-dd6d-8cbdc3c1a709
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8300:2C4BED:151B3CB:1ADB1EA:6B012E52
html-safe-nonce1e75d08763cb511982df053be219ccda53dba164a87bc7d5f3e41085efa40b94
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzAwOjJDNEJFRDoxNTFCM0NCOjFBREIxRUE6NkIwMTJFNTIiLCJ2aXNpdG9yX2lkIjoiNDA4NzM0NTc4MjY4Mjg4OTgxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac3d4f32b5d2029fa2775ab127ddbf7fa6110cbc50b70fd1bf0143ea29d5705aa6
hovercard-subject-tagissue:5070092066
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/3256/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9659b44eac12049ed2f03ffa145d42ffabd93cc17aeb6722626204aa713ac080/modelcontextprotocol/python-sdk/issues/3256
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9659b44eac12049ed2f03ffa145d42ffabd93cc17aeb6722626204aa713ac080/modelcontextprotocol/python-sdk/issues/3256
og:image:altInitial Checks I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1) I confirm that I searched for my issue in https://github.com/modelcontex...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecarrotRakko
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/3256#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3256
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3256
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3256
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3256
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3256
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues315 (315)https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests112 (112)https://github.com/modelcontextprotocol/python-sdk/pulls
Actionshttps://github.com/modelcontextprotocol/python-sdk/actions
Projectshttps://github.com/modelcontextprotocol/python-sdk/projects
Security and quality12 (12)https://github.com/modelcontextprotocol/python-sdk/security
Insightshttps://github.com/modelcontextprotocol/python-sdk/insights
https://github.com/modelcontextprotocol/python-sdk
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3256
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3256
#3264https://github.com/modelcontextprotocol/python-sdk/pull/3264
OAuth client can never recover from an expired DCR client secret — even though the SDK's own server issues and enforces onehttps://github.com/modelcontextprotocol/python-sdk/issues/3256#top
#3264https://github.com/modelcontextprotocol/python-sdk/pull/3264
P1Significant bug affecting many users, highly requested featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P1%22
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
https://github.com/carrotRakko
carrotRakkohttps://github.com/carrotRakko
on Aug 5, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3256#issue-5070092066
https://github.com/modelcontextprotocol/python-sdk/issueshttps://github.com/modelcontextprotocol/python-sdk/issues
a4f4ccdhttps://github.com/modelcontextprotocol/python-sdk/commit/a4f4ccd091138771535e17191123f20b30fda68e
a4f4ccdhttps://github.com/modelcontextprotocol/python-sdk/commit/a4f4ccd091138771535e17191123f20b30fda68e
a4f4ccdhttps://github.com/modelcontextprotocol/python-sdk/commit/a4f4ccd091138771535e17191123f20b30fda68e
a4f4ccdhttps://github.com/modelcontextprotocol/python-sdk/commit/a4f4ccd091138771535e17191123f20b30fda68e
a4f4ccdhttps://github.com/modelcontextprotocol/python-sdk/commit/a4f4ccd091138771535e17191123f20b30fda68e
@carrotRakkohttps://github.com/carrotRakko
maxisbeyhttps://github.com/maxisbey
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
P2Moderate issues affecting some users, edge cases, potentially valuable featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
P1Significant bug affecting many users, highly requested featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P1%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
P2Moderate issues affecting some users, edge cases, potentially valuable featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P2%22
on Aug 11, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3256#event-29288204603
https://github.com/carrotRakko
carrotRakkohttps://github.com/carrotRakko
on Aug 19, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3256#issuecomment-5344012621
@carrotRakkohttps://github.com/carrotRakko
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3256
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3256
P1Significant bug affecting many users, highly requested featurehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P1%22
bugSomething isn't workinghttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.