[PR #5211] [CLOSED] feat:(OLD) Allow passing additional data through OAuth flows #5854

Closed
opened 2026-03-13 12:39:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5211
Author: @ping-maxwell
Created: 10/10/2025
Status: Closed

Base: canaryHead: feat/oauth-additional-state


📝 Commits (1)

  • 3370ea0 feat: Allow passing additional data through OAuth flows

📊 Changes

10 files changed (+425 additions, -55 deletions)

View changed files

📝 docs/content/docs/concepts/oauth.mdx (+60 -0)
📝 packages/better-auth/src/api/routes/account.ts (+5 -1)
📝 packages/better-auth/src/api/routes/callback.ts (+18 -1)
📝 packages/better-auth/src/api/routes/sign-in.ts (+9 -1)
📝 packages/better-auth/src/db/internal-adapter.ts (+47 -0)
packages/better-auth/src/oauth2/additional-data.ts (+109 -0)
📝 packages/better-auth/src/oauth2/link-account.ts (+37 -36)
📝 packages/better-auth/src/oauth2/state.ts (+16 -3)
📝 packages/better-auth/src/plugins/generic-oauth/index.ts (+39 -12)
📝 packages/better-auth/src/types/options.ts (+85 -1)

📄 Description

WIP


Summary by cubic

Adds support for passing custom data through OAuth flows and mapping it into user, account, or session records. This enables optional schema validation and targeted assignment during sign-in or account linking.

  • New Features
    • Config: socialProviders.additionalData with enabled, schema (StandardSchemaV1), and assign hook to map fields into user/account/session.
    • Endpoints: signInSocial and linkSocialAccount now accept a data payload; state now carries additionalData through the flow.
    • Callbacks: OAuth callback and generic OAuth plugin merge additionalData when updating/creating user and linking accounts, including when overrideUserInfo is used.
    • Docs: Added a concepts/oauth section with examples and a callout on defining custom fields.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5211 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 10/10/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/oauth-additional-state` --- ### 📝 Commits (1) - [`3370ea0`](https://github.com/better-auth/better-auth/commit/3370ea05c455d1c24d31530823df082c8c33e836) feat: Allow passing additional data through OAuth flows ### 📊 Changes **10 files changed** (+425 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/oauth.mdx` (+60 -0) 📝 `packages/better-auth/src/api/routes/account.ts` (+5 -1) 📝 `packages/better-auth/src/api/routes/callback.ts` (+18 -1) 📝 `packages/better-auth/src/api/routes/sign-in.ts` (+9 -1) 📝 `packages/better-auth/src/db/internal-adapter.ts` (+47 -0) ➕ `packages/better-auth/src/oauth2/additional-data.ts` (+109 -0) 📝 `packages/better-auth/src/oauth2/link-account.ts` (+37 -36) 📝 `packages/better-auth/src/oauth2/state.ts` (+16 -3) 📝 `packages/better-auth/src/plugins/generic-oauth/index.ts` (+39 -12) 📝 `packages/better-auth/src/types/options.ts` (+85 -1) </details> ### 📄 Description WIP <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds support for passing custom data through OAuth flows and mapping it into user, account, or session records. This enables optional schema validation and targeted assignment during sign-in or account linking. - **New Features** - Config: socialProviders.additionalData with enabled, schema (StandardSchemaV1), and assign hook to map fields into user/account/session. - Endpoints: signInSocial and linkSocialAccount now accept a data payload; state now carries additionalData through the flow. - Callbacks: OAuth callback and generic OAuth plugin merge additionalData when updating/creating user and linking accounts, including when overrideUserInfo is used. - Docs: Added a concepts/oauth section with examples and a callout on defining custom fields. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:39:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#5854