René's URL Explorer Experiment


Title: M2MToken.fromJwtPayload drops custom claims by forcing claims to null · Issue #8680 · clerk/javascript · GitHub

Open Graph Title: M2MToken.fromJwtPayload drops custom claims by forcing claims to null · Issue #8680 · clerk/javascript

X Title: M2MToken.fromJwtPayload drops custom claims by forcing claims to null · Issue #8680 · clerk/javascript

Description: Preliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk support via email or Discord (if you hav...

Open Graph Description: Preliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk ...

X Description: Preliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk ...

Opengraph URL: https://github.com/clerk/javascript/issues/8680

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"M2MToken.fromJwtPayload drops custom claims by forcing claims to null","articleBody":"### Preliminary Checks\n\n- [x] I have reviewed the documentation: https://clerk.com/docs\n\n- [x] I have searched for existing issues: https://github.com/clerk/javascript/issues\n\n- [x] I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)\n\n- [x] This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.\n\n\n### Reproduction\n\nhttps://github.com/rubenqba/clerk-m2m-jwt-claims-issue\n\n### Publishable key\n\npk_test_Y3V0ZS1jcmF5ZmlzaC02Mi5jbGVyay5hY2NvdW50cy5kZXYk\n\n### Description\n\n**Steps to reproduce:**\n\n1. Create a machine-to-machine token in JWT format with custom claims, for example `permissions`.\n2. Verify the token with `@clerk/backend` using `client.m2m.verify({ token })`.\n3. Inspect the returned `M2MToken` object.\n4. Compare the verified result with the original JWT payload.\n\n**Expected behavior:**\n\nThe returned `M2MToken` should preserve the custom claims present in the JWT payload, or the SDK/documentation should explicitly state that custom claims are intentionally discarded for JWT-format M2M tokens.\n\n**Actual behavior:**\n\nThe returned `M2MToken` always has `claims = null` in the JWT verification path, even when the JWT itself clearly includes custom claims.\n\nThis confirms that the issue is not in token issuance, but in the transformation path inside `M2MToken.fromJwtPayload()`.\n\n**Evidence in source code:**\n\nThe issue appears to be in the Backend SDK transformation logic:\n\n- [packages/backend/src/api/resources/M2MToken.ts](https://github.com/clerk/javascript/blob/b07afc4b3e8a43232fe6cee4fb19a8c62d4bb09b/packages/backend/src/api/resources/M2MToken.ts#L54)\n- `M2MToken.fromJwtPayload()`\n\nThat method currently maps the JWT payload into an `M2MToken` and explicitly sets `claims` to `null`.\n\nThe JWT verification path appears to go through:\n\n- [packages/backend/src/api/endpoints/M2MTokenApi.ts](https://github.com/clerk/javascript/blob/b07afc4b3e8a43232fe6cee4fb19a8c62d4bb09b/packages/backend/src/api/endpoints/M2MTokenApi.ts#L194)\n\nFor JWT-format M2M tokens, verification succeeds, but the returned object loses custom claims during the `M2MToken.fromJwtPayload()` transformation.\n\nI also verified that the JWT itself does include the custom claims. Example token payload visible [here](https://jwt.io/#token=eyJhbGciOiJSUzI1NiIsImtpZCI6Imluc18yekVjSXlGc2NHUDE3UlNLNXFnajl3SUp1aUIiLCJ0eXAiOiJKV1QifQ.eyJwZXJtaXNzaW9ucyI6WyJyZWFkOnVzZXJzIiwicmVhZDpvcmRlcnMiXSwiaXNzIjoiaHR0cHM6Ly9jdXRlLWNyYXlmaXNoLTYyLmNsZXJrLmFjY291bnRzLmRldiIsInN1YiI6Im1jaF8zRUhRS2t5VG1jYUNPeHJmZFVWYmFXelRmVWYiLCJhdWQiOlsibWNoXzNFSGpJNHN1QlRMbDQyYXhtNUppcXlVUDJoZCJdLCJzY29wZXMiOiJtY2hfM0VIakk0c3VCVExsNDJheG01SmlxeVVQMmhkIiwianRpIjoibXRfNmEwZGRiNzIzNjE1OWMwOGQwZWM3ZmU0OTQxY2VhMDgiLCJpYXQiOjE3Nzk5MjAxNzksImV4cCI6MTc3OTkyMDE4OX0.NdThLJwvPRGbyHzky9YDdXUaccj-uHvmBYTkM6pG7XsWhTASksfBB0LMlFDGQobtmoVlh5rOG-R3C59_AsTp-ynqpwidpLt4j4BRW0SuEPdlVCU1haWaZXFO2eX3JcF0JQ1BW0G_B1DjY5sunmqWvf4MGUCUX70wDpyKs_WXpZgZoyH8yeIjowY8PddqDIVwLXChzmUvZ-0y8gQsUT0nyUxuTs82TjKKUmLmYDgJbFWJ1FsgWzGPFUT90vpKP2Wg1M8p_BGxAunG4cIXPYXdnmorB0Gz1259CKQaEnrALHV53TThWqinLiZ3F60Q9LZL-muWZgHuJG5IEwokLcpv_w):\n\nThat token payload includes:\n\n- `permissions`\n- `iss`\n- `sub`\n- `aud`\n- `scopes`\n- `jti`\n- `iat`\n- `exp`\n\nSo the loss of claims happens after decoding/verifying the JWT, during SDK mapping.\n\n**Impact:**\n\n- Applications cannot rely on `M2MToken.claims` when using JWT-format M2M tokens.\n- Authorization flows based on custom claims break silently.\n- This creates inconsistent behavior between the JWT payload and the verified SDK object.\n- It is especially confusing because verification succeeds, but claim data is dropped.\n\n**Related PRs:**\n\nFrom the implementation history, it looks like this behavior appears to have been introduced when JWT support for M2M verification was added:\n\n- https://github.com/clerk/javascript/pull/7883\n- https://github.com/clerk/javascript/pull/7955\n\n\n### Environment\n\n```Shell\nSystem:\n    OS: macOS 26.5\n    CPU: (10) arm64 Apple M5\n    Memory: 82.28 MB / 24.00 GB\n    Shell: 5.9 - /bin/zsh\n  Binaries:\n    Node: 24.15.0 - $HOME/.local/state/fnm_multishells/71323_1779899590505/bin/node\n    npm: 11.12.1 - $HOME/.local/state/fnm_multishells/71323_1779899590505/bin/npm\n    pnpm: 11.3.0 - $HOME/Library/pnpm/pnpm\n  Browsers:\n    Chrome: 148.0.7778.181\n    Safari: 26.5\n  npmPackages:\n    @eslint/js: ^10.0.1 => 10.0.1 \n    @typescript-eslint/eslint-plugin: ^8.59.4 => 8.59.4 \n    @typescript-eslint/parser: ^8.59.4 => 8.59.4 \n    @typescript-eslint/utils: ^8.59.4 => 8.59.4 \n    eslint: ^10.4.0 => 10.4.0 \n    husky: ^9.1.7 => 9.1.7 \n    lint-staged: ^17.0.5 => 17.0.5 \n    prettier: ^3.8.3 => 3.8.3 \n    turbo: ^2.9.14 => 2.9.14 \n    typescript: ^6.0.3 => 6.0.3 \n    typescript-eslint: ^8.59.4 => 8.59.4 \n    zod: ^4.4.3 => 4.4.3\n```","author":{"url":"https://github.com/rubenqba","@type":"Person","name":"rubenqba"},"datePublished":"2026-05-27T23:51:11Z","url":"https://github.com/clerk/javascript/issues/8680"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:fd1a0450-b3a4-53ca-cc60-c53f14286283
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id89F4:370E32:122164A:18BFB47:6AFB6B61
html-safe-nonce8250100d6d5b55772861e2ebcbfbeb99ea4549e8043d344e7c2022b501377a9f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OUY0OjM3MEUzMjoxMjIxNjRBOjE4QkZCNDc6NkFGQjZCNjEiLCJ2aXNpdG9yX2lkIjoiNTQ0NzUyMjA0NjU1NDM2ODg2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac72764795d40a3ceb6a259edda77a7540d239f6fdffa1d2289dd9f61c928f9298
hovercard-subject-tagissue:4536551611
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/clerk/javascript/8680/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f2e3fb95382359713851e2350db564d61bb3611b9a4ef2a0f48ca37e2c0eabb0/clerk/javascript/issues/8680
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f2e3fb95382359713851e2350db564d61bb3611b9a4ef2a0f48ca37e2c0eabb0/clerk/javascript/issues/8680
og:image:altPreliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerubenqba
hostnamegithub.com
expected-hostnamegithub.com
Nonecca289ecd54650fcf3c0b037a58b97186dee2cc4406819d87fab93728fd83700
turbo-cache-controlno-preview
go-importgithub.com/clerk/javascript git https://github.com/clerk/javascript.git
octolytics-dimension-user_id49538330
octolytics-dimension-user_loginclerk
octolytics-dimension-repository_id438331492
octolytics-dimension-repository_nwoclerk/javascript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id438331492
octolytics-dimension-repository_network_root_nwoclerk/javascript
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
release88808b1fae5ab8a526a73e7ce5542a10eb9d6971
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/clerk/javascript/issues/8680#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fclerk%2Fjavascript%2Fissues%2F8680
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%2Fclerk%2Fjavascript%2Fissues%2F8680
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=clerk%2Fjavascript
Reloadhttps://github.com/clerk/javascript/issues/8680
Reloadhttps://github.com/clerk/javascript/issues/8680
Reloadhttps://github.com/clerk/javascript/issues/8680
clerkhttps://github.com/clerk
javascripthttps://github.com/clerk/javascript
Codehttps://github.com/clerk/javascript
Issues45 (45)https://github.com/clerk/javascript/issues
Pull requests109 (109)https://github.com/clerk/javascript/pulls
Discussionshttps://github.com/clerk/javascript/discussions
Actionshttps://github.com/clerk/javascript/actions
Security and quality6 (6)https://github.com/clerk/javascript/security
Insightshttps://github.com/clerk/javascript/pulse
https://github.com/clerk/javascript
New issuehttps://github.com/login?return_to=https://github.com/clerk/javascript/issues/8680
New issuehttps://github.com/login?return_to=https://github.com/clerk/javascript/issues/8680
#8697https://github.com/clerk/javascript/pull/8697
M2MToken.fromJwtPayload drops custom claims by forcing claims to nullhttps://github.com/clerk/javascript/issues/8680#top
#8697https://github.com/clerk/javascript/pull/8697
https://github.com/jacekradko
https://github.com/rubenqba
rubenqbahttps://github.com/rubenqba
on May 27, 2026https://github.com/clerk/javascript/issues/8680#issue-4536551611
https://clerk.com/docshttps://clerk.com/docs
https://github.com/clerk/javascript/issueshttps://github.com/clerk/javascript/issues
https://clerk.com/discordhttps://clerk.com/discord
https://github.com/rubenqba/clerk-m2m-jwt-claims-issuehttps://github.com/rubenqba/clerk-m2m-jwt-claims-issue
packages/backend/src/api/resources/M2MToken.tshttps://github.com/clerk/javascript/blob/b07afc4b3e8a43232fe6cee4fb19a8c62d4bb09b/packages/backend/src/api/resources/M2MToken.ts#L54
packages/backend/src/api/endpoints/M2MTokenApi.tshttps://github.com/clerk/javascript/blob/b07afc4b3e8a43232fe6cee4fb19a8c62d4bb09b/packages/backend/src/api/endpoints/M2MTokenApi.ts#L194
herehttps://jwt.io/#token=eyJhbGciOiJSUzI1NiIsImtpZCI6Imluc18yekVjSXlGc2NHUDE3UlNLNXFnajl3SUp1aUIiLCJ0eXAiOiJKV1QifQ.eyJwZXJtaXNzaW9ucyI6WyJyZWFkOnVzZXJzIiwicmVhZDpvcmRlcnMiXSwiaXNzIjoiaHR0cHM6Ly9jdXRlLWNyYXlmaXNoLTYyLmNsZXJrLmFjY291bnRzLmRldiIsInN1YiI6Im1jaF8zRUhRS2t5VG1jYUNPeHJmZFVWYmFXelRmVWYiLCJhdWQiOlsibWNoXzNFSGpJNHN1QlRMbDQyYXhtNUppcXlVUDJoZCJdLCJzY29wZXMiOiJtY2hfM0VIakk0c3VCVExsNDJheG01SmlxeVVQMmhkIiwianRpIjoibXRfNmEwZGRiNzIzNjE1OWMwOGQwZWM3ZmU0OTQxY2VhMDgiLCJpYXQiOjE3Nzk5MjAxNzksImV4cCI6MTc3OTkyMDE4OX0.NdThLJwvPRGbyHzky9YDdXUaccj-uHvmBYTkM6pG7XsWhTASksfBB0LMlFDGQobtmoVlh5rOG-R3C59_AsTp-ynqpwidpLt4j4BRW0SuEPdlVCU1haWaZXFO2eX3JcF0JQ1BW0G_B1DjY5sunmqWvf4MGUCUX70wDpyKs_WXpZgZoyH8yeIjowY8PddqDIVwLXChzmUvZ-0y8gQsUT0nyUxuTs82TjKKUmLmYDgJbFWJ1FsgWzGPFUT90vpKP2Wg1M8p_BGxAunG4cIXPYXdnmorB0Gz1259CKQaEnrALHV53TThWqinLiZ3F60Q9LZL-muWZgHuJG5IEwokLcpv_w
feat(backend,nextjs): Add support for M2M JWT creation and verification #7883https://github.com/clerk/javascript/pull/7883
feat(backend,nextjs): Add support for M2M JWT creation and verification #7955https://github.com/clerk/javascript/pull/7955
rubenqbahttps://github.com/rubenqba
needs-triageA ticket that needs to be triaged by a team memberhttps://github.com/clerk/javascript/issues?q=state%3Aopen%20label%3A%22needs-triage%22
on May 27, 2026https://github.com/clerk/javascript/issues/8680#event-26039565099
jacekradkohttps://github.com/jacekradko
needs-triageA ticket that needs to be triaged by a team memberhttps://github.com/clerk/javascript/issues?q=state%3Aopen%20label%3A%22needs-triage%22
on May 28, 2026https://github.com/clerk/javascript/issues/8680#event-26080443676
jacekradkohttps://github.com/jacekradko
on May 28, 2026https://github.com/clerk/javascript/issues/8680#event-26080445177
jacekradkohttps://github.com/jacekradko
completedhttps://github.com/clerk/javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#8697https://github.com/clerk/javascript/pull/8697
on May 29, 2026https://github.com/clerk/javascript/issues/8680#event-26119393944
Sign up for freehttps://github.com/signup?return_to=https://github.com/clerk/javascript/issues/8680
Sign in to commenthttps://github.com/login?return_to=https://github.com/clerk/javascript/issues/8680
jacekradkohttps://github.com/jacekradko
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.