Skip to content

Conversation

@jfoshee
Copy link
Contributor

@jfoshee jfoshee commented Jan 12, 2026

Description

Adds an optional idToken member to the OauthAccessToken object returned by getUserOauthAccessToken. This idToken represents the ID token retrieved from OIDC providers, and is only present for OIDC-compliant OAuth 2.0 providers when available.

This change involves:

  • Adding id_token?: string to the OauthAccessTokenJSON interface in JSON.ts.
  • Adding idToken?: string to the OauthAccessToken class constructor and updating the fromJSON method in OauthAccessToken.ts.
  • Adding JSDoc comments for the new idToken property.

API Changes

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Open in Cursor Open in Web

Summary by CodeRabbit

  • New Features
    • OAuth access tokens now optionally include ID tokens from OpenID Connect-compliant providers. When available from your OAuth provider, the ID token delivers additional user identity information for enhanced security and user verification. This is only included when your provider supports OpenID Connect and returns an ID token in the response.

✏️ Tip: You can customize this high-level summary in your review settings.

Co-authored-by: jacob.foshee <jacob.foshee@clerk.dev>
@cursor
Copy link

cursor bot commented Jan 12, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@changeset-bot
Copy link

changeset-bot bot commented Jan 12, 2026

🦋 Changeset detected

Latest commit: 3264e22

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@clerk/backend Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jan 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jan 12, 2026 11:56pm

Co-authored-by: jacob.foshee <jacob.foshee@clerk.dev>
@jfoshee jfoshee changed the title Oauth idToken member feat(backend): add OauthAccessToken idToken member Jan 12, 2026
@jfoshee jfoshee changed the title feat(backend): add OauthAccessToken idToken member feat(backend): Add OauthAccessToken idToken member Jan 12, 2026
@jfoshee jfoshee marked this pull request as ready for review January 13, 2026 20:38
@jfoshee jfoshee requested review from a team and tmilewski January 13, 2026 20:39
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

This pull request adds support for ID tokens in OAuth access token handling. An optional idToken field is introduced to the OauthAccessToken class and OauthAccessTokenJSON interface. The field is populated from OIDC-compliant OAuth 2.0 providers when available. The implementation includes updating the OauthAccessToken constructor to accept the idToken parameter as a public readonly property, and the fromJSON method now maps the id_token field from the JSON representation to the idToken property. No behavioral changes occur when the token is not provided by the OAuth provider.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding an optional idToken member to the OauthAccessToken class to expose ID tokens from OIDC providers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 04c6245 and 3264e22.

📒 Files selected for processing (3)
  • .changeset/oauth-idtoken-member.md
  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Files:

  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use ESLint with custom configurations tailored for different package types

Files:

  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use Prettier for code formatting across all packages

Files:

  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
**/*

⚙️ CodeRabbit configuration file

If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.

**/*: Only comment on issues that would block merging, ignore minor or stylistic concerns.
Restrict feedback to errors, security risks, or functionality-breaking problems.
Do not post comments on code style, formatting, or non-critical improvements.
Keep reviews short: flag only issues that make the PR unsafe to merge.
Group similar issues into a single comment instead of posting multiple notes.
Skip repetition: if a pattern repeats, mention it once at a summary level only.
Do not add general suggestions, focus strictly on merge-blocking concerns.
If there are no critical problems, respond with minimal approval (e.g., 'Looks good'). Do not add additional review.
Avoid line-by-line commentary unless it highlights a critical bug or security hole.
Highlight only issues that could cause runtime errors, data loss, or severe maintainability issues.
Ignore minor optimization opportunities, focus solely on correctness and safety.
Provide a top-level summary of critical blockers rather than detailed per-line notes.
Comment only when the issue must be resolved before merge, otherwise remain silent.
When in doubt, err on the side of fewer comments, brevity and blocking issues only.
Avoid posting any refactoring issues.

Files:

  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/OauthAccessToken.ts
🔇 Additional comments (3)
packages/backend/src/api/resources/JSON.ts (1)

291-305: LGTM!

The optional id_token field follows the established pattern in this interface and is correctly typed.

packages/backend/src/api/resources/OauthAccessToken.ts (1)

13-17: LGTM!

The idToken property is correctly added with proper JSDoc documentation, and the fromJSON mapping follows the established snake_case to camelCase conversion pattern used for other fields.

Also applies to: 30-30

.changeset/oauth-idtoken-member.md (1)

1-5: LGTM!

Changeset is correctly formatted with an appropriate patch version bump for this backward-compatible feature addition.


Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants