[PR #2147] [MERGED] fix: genericOAuth default redirectURI for account linking #4178

Closed
opened 2026-03-13 11:35:54 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2147
Author: @dbworku
Created: 4/6/2025
Status: Merged
Merged: 4/6/2025
Merged by: @Bekacru

Base: mainHead: dbworku/generic-oauth-redirect-uri-fix


📝 Commits (2)

  • 388505d fix: genericOAuth default redirectURI for account linking
  • f456481 chore: lint

📊 Changes

1 file changed (+2 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/plugins/generic-oauth/index.ts (+2 -1)

📄 Description

I noticed that oauth flow for oauth2.link is defaulting to the wrong redirect uri.

Expected

Given the base url is https://www.example.com and a generic oauth plugin config like:

{
    providerId: "slack",
    clientId: env.SLACK_CLIENT_ID,
    clientSecret: env.SLACK_CLIENT_SECRET,
    discoveryUrl: "https://slack.com/.well-known/openid-configuration",
    scopes: ["openid", "email", "profile"]
}

I would expect that oauth2.link redirects to https://www.example.com/api/auth/oauth2/callback/slack.

Current State

I'm seeing an incorrect redirect to https://www.example.com/api/auth/oauth2/callback. Looking at the code this is becuase we've hardcoded that as the default.

NOTE: This is only an issue for generic oauth linking. signIn.oauth2 correctly includes the provider id at the end of the redirect URI.


🔄 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/2147 **Author:** [@dbworku](https://github.com/dbworku) **Created:** 4/6/2025 **Status:** ✅ Merged **Merged:** 4/6/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `dbworku/generic-oauth-redirect-uri-fix` --- ### 📝 Commits (2) - [`388505d`](https://github.com/better-auth/better-auth/commit/388505d22b4857dc35059f8c41c06ff492953be0) fix: genericOAuth default redirectURI for account linking - [`f456481`](https://github.com/better-auth/better-auth/commit/f456481d6ae23c2a0fd0a450775dfcb225051c7b) chore: lint ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/generic-oauth/index.ts` (+2 -1) </details> ### 📄 Description I noticed that oauth flow for `oauth2.link` is defaulting to the wrong redirect uri. ## Expected Given the base url is ` https://www.example.com` and a generic oauth plugin config like: ``` { providerId: "slack", clientId: env.SLACK_CLIENT_ID, clientSecret: env.SLACK_CLIENT_SECRET, discoveryUrl: "https://slack.com/.well-known/openid-configuration", scopes: ["openid", "email", "profile"] } ``` I would expect that `oauth2.link` redirects to `https://www.example.com/api/auth/oauth2/callback/slack`. ## Current State I'm seeing an incorrect redirect to `https://www.example.com/api/auth/oauth2/callback`. Looking at the code this is becuase we've hardcoded that as the default. NOTE: This is only an issue for generic oauth linking. `signIn.oauth2` correctly includes the provider id at the end of the redirect URI. --- <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 11:35:54 -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#4178