[PR #4583] [CLOSED] feat: add support for multiple Google client IDs for cross-platform authentication #5463

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4583
Author: @RikhiSingh
Created: 9/11/2025
Status: Closed

Base: canaryHead: feat/google-multiple-client-ids


📝 Commits (6)

  • a1fd99b feat(google): support multiple client IDs for OAuth2 provider
  • b757128 chore: update biome schema version and clean up imports in mobile navigation component
  • 4207199 Merge branch 'canary' into feat/google-multiple-client-ids
  • c773c99 docs: enhance Google authentication documentation for multiple client IDs
  • f7998a9 refactor(auth): simplify clientId type in ProviderOptions and GoogleOptions
  • 9b63876 fix(auth): handle empty clientId array in Google provider

📊 Changes

6 files changed (+421 additions, -9 deletions)

View changed files

📝 biome.json (+1 -1)
📝 docs/components/nav-mobile.tsx (+1 -2)
📝 docs/content/docs/authentication/google.mdx (+25 -0)
📝 docs/content/docs/concepts/oauth.mdx (+21 -0)
📝 packages/better-auth/src/social-providers/google.ts (+52 -6)
packages/better-auth/src/social-providers/test/google-multiple-client-ids.test.ts (+321 -0)

📄 Description

Description

Adds support for configuring multiple Google OAuth client IDs in a single better-auth configuration, enabling cross-platform authentication where different platforms (iOS, Android, Web) can use their respective Google OAuth client IDs while authenticating with the same backend API.

Problem

Currently, better-auth only supports a single Google client ID. This breaks cross-platform authentication where:

  • iOS app uses: 123-ios.googleusercontent.com
  • Android app uses: 456-android.googleusercontent.com
  • Both need to authenticate with the same backend

Solution

  • Extended GoogleOptions interface to accept clientId as string | string[]
  • Updated verifyIdToken to validate against any configured client ID
  • Maintained backward compatibility and security

Usage

export const auth = betterAuth({
  socialProviders: {
    google: {
      clientId: [
        "123-ios.googleusercontent.com",
        "456-android.googleusercontent.com", 
        "789-web.googleusercontent.com"
      ],
      clientSecret: "your-client-secret",
    },
  },
});

Testing

  • 16 test cases covering all scenarios
  • Backward compatible
  • No breaking changes

Closes #4498


Summary by cubic

Add support for multiple Google OAuth client IDs to enable cross-platform sign-in (iOS, Android, Web) against the same backend. Backward compatible; ID tokens are validated against any configured client ID.

  • New Features

    • clientId accepts string | string[] in ProviderOptions (Google only)
    • Google provider uses the first client ID for auth URL, token exchange, and refresh
    • verifyIdToken checks aud against any configured client ID and validates issuer
    • Added tests to cover single and multiple client ID flows
  • Refactors

    • Updated Biome schema to 2.2.3
    • Removed unused import in nav-mobile.tsx

🔄 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/4583 **Author:** [@RikhiSingh](https://github.com/RikhiSingh) **Created:** 9/11/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/google-multiple-client-ids` --- ### 📝 Commits (6) - [`a1fd99b`](https://github.com/better-auth/better-auth/commit/a1fd99b4ae6da3e13b6bf12ed5c90c0628855adb) feat(google): support multiple client IDs for OAuth2 provider - [`b757128`](https://github.com/better-auth/better-auth/commit/b7571288ee55fbf2fec5179e71cbd0c89d1df2f3) chore: update biome schema version and clean up imports in mobile navigation component - [`4207199`](https://github.com/better-auth/better-auth/commit/4207199c450be4be1bb7039b4ebf35f29563e8e2) Merge branch 'canary' into feat/google-multiple-client-ids - [`c773c99`](https://github.com/better-auth/better-auth/commit/c773c99f2854230ac8765428047c55e8016e1797) docs: enhance Google authentication documentation for multiple client IDs - [`f7998a9`](https://github.com/better-auth/better-auth/commit/f7998a98c6a63e9ac41790a93781579186bb631e) refactor(auth): simplify clientId type in ProviderOptions and GoogleOptions - [`9b63876`](https://github.com/better-auth/better-auth/commit/9b6387638a959fa6beb3f497e8fcbdbe7de65ef6) fix(auth): handle empty clientId array in Google provider ### 📊 Changes **6 files changed** (+421 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `biome.json` (+1 -1) 📝 `docs/components/nav-mobile.tsx` (+1 -2) 📝 `docs/content/docs/authentication/google.mdx` (+25 -0) 📝 `docs/content/docs/concepts/oauth.mdx` (+21 -0) 📝 `packages/better-auth/src/social-providers/google.ts` (+52 -6) ➕ `packages/better-auth/src/social-providers/test/google-multiple-client-ids.test.ts` (+321 -0) </details> ### 📄 Description ## Description Adds support for configuring multiple Google OAuth client IDs in a single better-auth configuration, enabling cross-platform authentication where different platforms (iOS, Android, Web) can use their respective Google OAuth client IDs while authenticating with the same backend API. ## Problem Currently, better-auth only supports a single Google client ID. This breaks cross-platform authentication where: - iOS app uses: `123-ios.googleusercontent.com` - Android app uses: `456-android.googleusercontent.com` - Both need to authenticate with the same backend ## Solution - Extended `GoogleOptions` interface to accept `clientId` as `string | string[]` - Updated `verifyIdToken` to validate against any configured client ID - Maintained backward compatibility and security ## Usage ```typescript export const auth = betterAuth({ socialProviders: { google: { clientId: [ "123-ios.googleusercontent.com", "456-android.googleusercontent.com", "789-web.googleusercontent.com" ], clientSecret: "your-client-secret", }, }, }); ``` ## Testing - ✅ 16 test cases covering all scenarios - ✅ Backward compatible - ✅ No breaking changes Closes #4498 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add support for multiple Google OAuth client IDs to enable cross-platform sign-in (iOS, Android, Web) against the same backend. Backward compatible; ID tokens are validated against any configured client ID. - New Features - clientId accepts string | string[] in ProviderOptions (Google only) - Google provider uses the first client ID for auth URL, token exchange, and refresh - verifyIdToken checks aud against any configured client ID and validates issuer - Added tests to cover single and multiple client ID flows - Refactors - Updated Biome schema to 2.2.3 - Removed unused import in nav-mobile.tsx <!-- 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:23:40 -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#5463