[PR #6541] fix: apply authorizationUrlParams correctly in genericOAuth plugin #6733

Open
opened 2026-03-13 13:09:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6541
Author: @yoshifumi-kondo
Created: 12/5/2025
Status: 🔄 Open

Base: canaryHead: fix/generic-oauth-authorization-url-params


📝 Commits (3)

  • 470d6b8 fix: apply authorizationUrlParams correctly in genericOAuth plugin
  • 40db909 Merge branch 'canary' into fix/generic-oauth-authorization-url-params
  • 04fbf9e Merge branch 'canary' into fix/generic-oauth-authorization-url-params

📊 Changes

2 files changed (+87 additions, -9 deletions)

View changed files

📝 packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.ts (+87 -0)
📝 packages/better-auth/src/plugins/generic-oauth/routes.ts (+0 -9)

📄 Description

Summary

Fixed a bug where authorizationUrlParams was not being applied correctly in the genericOAuth plugin. The issue was caused by duplicate processing of the parameter, where function-based parameters were ignored in the first pass.

Changes

  • Removed redundant authorizationUrlParams processing (lines 166-174 in routes.ts)
  • Kept the correct implementation that properly evaluates both static objects and function-based parameters
  • Added test cases for both static and function-based authorizationUrlParams

Issue

Fixes #6486

Test Plan

  • Added test case for static authorizationUrlParams
  • Added test case for function-based authorizationUrlParams
  • Verified that both test cases correctly check if parameters are included in the authorization URL
  • Ran pnpm format and pnpm lint - no issues

Impact

This fix ensures that users can now use function-based authorizationUrlParams to dynamically set authorization parameters based on the request context, as originally intended by the API design.


Summary by cubic

Fixes authorizationUrlParams handling in genericOAuth so function-based params are applied. Both static and function-based params are now correctly included in the authorization URL.

  • Bug Fixes
    • Removed duplicate authorizationUrlParams processing in signInWithOAuth2.
    • Kept the implementation that evaluates both objects and functions.
    • Added tests for static and function-based params to verify URL inclusion.

Written for commit 04fbf9e84f. Summary will update automatically on new commits.


🔄 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/6541 **Author:** [@yoshifumi-kondo](https://github.com/yoshifumi-kondo) **Created:** 12/5/2025 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `fix/generic-oauth-authorization-url-params` --- ### 📝 Commits (3) - [`470d6b8`](https://github.com/better-auth/better-auth/commit/470d6b80a091c7798c0c5b5b06a060789056f524) fix: apply authorizationUrlParams correctly in genericOAuth plugin - [`40db909`](https://github.com/better-auth/better-auth/commit/40db90910c013c9f27a7ae8bd333df08db1c3c01) Merge branch 'canary' into fix/generic-oauth-authorization-url-params - [`04fbf9e`](https://github.com/better-auth/better-auth/commit/04fbf9e84febe42c942c807eebc929f38f841c0a) Merge branch 'canary' into fix/generic-oauth-authorization-url-params ### 📊 Changes **2 files changed** (+87 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.ts` (+87 -0) 📝 `packages/better-auth/src/plugins/generic-oauth/routes.ts` (+0 -9) </details> ### 📄 Description ## Summary Fixed a bug where `authorizationUrlParams` was not being applied correctly in the `genericOAuth` plugin. The issue was caused by duplicate processing of the parameter, where function-based parameters were ignored in the first pass. ## Changes - Removed redundant `authorizationUrlParams` processing (lines 166-174 in `routes.ts`) - Kept the correct implementation that properly evaluates both static objects and function-based parameters - Added test cases for both static and function-based `authorizationUrlParams` ## Issue Fixes #6486 ## Test Plan - [x] Added test case for static `authorizationUrlParams` - [x] Added test case for function-based `authorizationUrlParams` - [x] Verified that both test cases correctly check if parameters are included in the authorization URL - [x] Ran `pnpm format` and `pnpm lint` - no issues ## Impact This fix ensures that users can now use function-based `authorizationUrlParams` to dynamically set authorization parameters based on the request context, as originally intended by the API design. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes authorizationUrlParams handling in genericOAuth so function-based params are applied. Both static and function-based params are now correctly included in the authorization URL. - **Bug Fixes** - Removed duplicate authorizationUrlParams processing in signInWithOAuth2. - Kept the implementation that evaluates both objects and functions. - Added tests for static and function-based params to verify URL inclusion. <sup>Written for commit 04fbf9e84febe42c942c807eebc929f38f841c0a. Summary will update automatically on new commits.</sup> <!-- 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 13:09:47 -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#6733