[PR #2120] [MERGED] fix(oauth2): encode clientId and clientSecret in authorization header #12409

Closed
opened 2026-04-13 08:22:00 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2120
Author: @xinyao27
Created: 4/4/2025
Status: Merged
Merged: 4/5/2025
Merged by: @Bekacru

Base: mainHead: main


📝 Commits (3)

  • 574f6cc fix(oauth2): encode clientId and clientSecret in authorization header
  • 74711be fix(oauth2): refactor to use encodeOAuthParameter for clientId and clientSecret
  • 0023c29 chore: lint

📊 Changes

3 files changed (+11 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/oauth2/refresh-access-token.ts (+4 -1)
📝 packages/better-auth/src/oauth2/utils.ts (+3 -0)
📝 packages/better-auth/src/oauth2/validate-authorization-code.ts (+4 -1)

📄 Description

Hi, I found that I always encounter errors when using genericOAuth:

 {
  error: 'invalid_client',
  error_description: 'Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method).',
  status: 401,
  statusText: 'Unauthorized'
}

My client_secret contained characters like '+' '=' which didn't seem to be escaped correctly, so I created this PR to fix the issue


🔄 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/2120 **Author:** [@xinyao27](https://github.com/xinyao27) **Created:** 4/4/2025 **Status:** ✅ Merged **Merged:** 4/5/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (3) - [`574f6cc`](https://github.com/better-auth/better-auth/commit/574f6ccebc895a1c70cd3abbac2cd7be47172d3c) fix(oauth2): encode clientId and clientSecret in authorization header - [`74711be`](https://github.com/better-auth/better-auth/commit/74711be9e60b6e5b252135fef8a31ba3227911cd) fix(oauth2): refactor to use encodeOAuthParameter for clientId and clientSecret - [`0023c29`](https://github.com/better-auth/better-auth/commit/0023c29da50726a55377b9462a0d65f50df3defe) chore: lint ### 📊 Changes **3 files changed** (+11 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/oauth2/refresh-access-token.ts` (+4 -1) 📝 `packages/better-auth/src/oauth2/utils.ts` (+3 -0) 📝 `packages/better-auth/src/oauth2/validate-authorization-code.ts` (+4 -1) </details> ### 📄 Description Hi, I found that I always encounter errors when using genericOAuth: ``` { error: 'invalid_client', error_description: 'Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method).', status: 401, statusText: 'Unauthorized' } ``` My client_secret contained characters like '+' '=' which didn't seem to be escaped correctly, so I created this PR to fix the issue --- <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-13 08:22:00 -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#12409