[PR #4598] [MERGED] fix: pick the first clientId for oauth provider #31073

Closed
opened 2026-04-17 22:00:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4598
Author: @himself65
Created: 9/12/2025
Status: Merged
Merged: 9/12/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/09/11/client-id


📝 Commits (1)

  • 005384d fix: pick the first clientId for oauth provider

📊 Changes

4 files changed (+29 additions, -38 deletions)

View changed files

📝 packages/better-auth/src/oauth2/client-credentials-token.ts (+8 -11)
📝 packages/better-auth/src/oauth2/create-authorization-url.ts (+4 -8)
📝 packages/better-auth/src/oauth2/refresh-access-token.ts (+9 -10)
📝 packages/better-auth/src/oauth2/validate-authorization-code.ts (+8 -9)

📄 Description

Fixes: https://github.com/better-auth/better-auth/pull/4596#discussion_r2342624730

/cc @RikhiSingh


Summary by cubic

Always use the first clientId when an array is provided and switch to standard Base64 for Basic auth. This fixes OAuth flows that failed with providers expecting a single client_id.

  • Bug Fixes
    • Pick the first clientId across all OAuth requests (authorization URL, auth code, refresh token, client credentials).
    • Send a single client_id and use RFC 7617 Basic auth (base64 instead of base64Url).
    • Improves compatibility with providers that reject multiple client_id values (e.g., Notion, Twitter).

🔄 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/4598 **Author:** [@himself65](https://github.com/himself65) **Created:** 9/12/2025 **Status:** ✅ Merged **Merged:** 9/12/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/09/11/client-id` --- ### 📝 Commits (1) - [`005384d`](https://github.com/better-auth/better-auth/commit/005384dad260e10b8e0ed0ad58b186d12d8f5fe9) fix: pick the first clientId for oauth provider ### 📊 Changes **4 files changed** (+29 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/oauth2/client-credentials-token.ts` (+8 -11) 📝 `packages/better-auth/src/oauth2/create-authorization-url.ts` (+4 -8) 📝 `packages/better-auth/src/oauth2/refresh-access-token.ts` (+9 -10) 📝 `packages/better-auth/src/oauth2/validate-authorization-code.ts` (+8 -9) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/pull/4596#discussion_r2342624730 /cc @RikhiSingh <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Always use the first clientId when an array is provided and switch to standard Base64 for Basic auth. This fixes OAuth flows that failed with providers expecting a single client_id. - **Bug Fixes** - Pick the first clientId across all OAuth requests (authorization URL, auth code, refresh token, client credentials). - Send a single client_id and use RFC 7617 Basic auth (base64 instead of base64Url). - Improves compatibility with providers that reject multiple client_id values (e.g., Notion, Twitter). <!-- 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:46 -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#31073