[PR #4576] feat(social-provider): multiple client ID support for social providers #31058

Open
opened 2026-04-17 22:00:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4576
Author: @Kinfe123
Created: 9/10/2025
Status: 🔄 Open

Base: nextHead: feat/multiple-client-ids-social-providers


📝 Commits (4)

📊 Changes

8 files changed (+316 additions, -11 deletions)

View changed files

📝 docs/content/docs/authentication/google.mdx (+87 -0)
📝 packages/better-auth/src/api/routes/callback.ts (+2 -0)
📝 packages/better-auth/src/api/routes/sign-in.ts (+14 -0)
📝 packages/better-auth/src/oauth2/state.ts (+2 -0)
📝 packages/better-auth/src/oauth2/types.ts (+2 -0)
📝 packages/better-auth/src/social-providers/google.ts (+54 -11)
packages/better-auth/src/social-providers/multiple-client-config.ts (+72 -0)
📝 packages/better-auth/src/social-providers/social.test.ts (+83 -0)

📄 Description

Summary by cubic

Add multiple client ID support for social providers (initially Google) so apps can choose a client per request (web, iOS, Android) while keeping current setups working by default. Token validation now accepts any configured client ID.

  • New Features

    • signInSocial accepts optional clientId; stored in state and used in callback for code exchange.
    • Added SocialProviderMultipleClientOptions with configs[] for per-platform clientId/secret/scopes/redirectURI.
    • OAuth provider types now accept clientId in authorization URL and code validation flows.
    • Google provider resolves the requested client config, merges scopes, uses per-client redirectURI, and validates token aud against all configured client IDs.
    • Tests cover iOS/Android/web selection and fallback on invalid clientId.
  • Migration

    • No breaking changes.
    • To use: define google.configs[] and pass clientId in signInSocial when selecting a specific client; otherwise the default client is used.

🔄 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/4576 **Author:** [@Kinfe123](https://github.com/Kinfe123) **Created:** 9/10/2025 **Status:** 🔄 Open **Base:** `next` ← **Head:** `feat/multiple-client-ids-social-providers` --- ### 📝 Commits (4) - [`dda2ff7`](https://github.com/better-auth/better-auth/commit/dda2ff790b905158c1523aaeaa17f1de3c5eacf4) fix: tiktok scope - [`45ef274`](https://github.com/better-auth/better-auth/commit/45ef274cabddb812a085a3483e5c0c66572c5eb7) feat(social-provider): multiple client ID support for social providers - [`41912e4`](https://github.com/better-auth/better-auth/commit/41912e4af26dea080334e83829318102ea817bcd) lint - [`6b9c581`](https://github.com/better-auth/better-auth/commit/6b9c581a5d8f3df8e716f02b9dea4483264fc66f) docs ### 📊 Changes **8 files changed** (+316 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/authentication/google.mdx` (+87 -0) 📝 `packages/better-auth/src/api/routes/callback.ts` (+2 -0) 📝 `packages/better-auth/src/api/routes/sign-in.ts` (+14 -0) 📝 `packages/better-auth/src/oauth2/state.ts` (+2 -0) 📝 `packages/better-auth/src/oauth2/types.ts` (+2 -0) 📝 `packages/better-auth/src/social-providers/google.ts` (+54 -11) ➕ `packages/better-auth/src/social-providers/multiple-client-config.ts` (+72 -0) 📝 `packages/better-auth/src/social-providers/social.test.ts` (+83 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add multiple client ID support for social providers (initially Google) so apps can choose a client per request (web, iOS, Android) while keeping current setups working by default. Token validation now accepts any configured client ID. - New Features - signInSocial accepts optional clientId; stored in state and used in callback for code exchange. - Added SocialProviderMultipleClientOptions with configs[] for per-platform clientId/secret/scopes/redirectURI. - OAuth provider types now accept clientId in authorization URL and code validation flows. - Google provider resolves the requested client config, merges scopes, uses per-client redirectURI, and validates token aud against all configured client IDs. - Tests cover iOS/Android/web selection and fallback on invalid clientId. - Migration - No breaking changes. - To use: define google.configs[] and pass clientId in signInSocial when selecting a specific client; otherwise the default client is used. <!-- 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-04-17 22:00: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#31058