[PR #8814] feat: allow OAuth endpoint overrides for social providers #16477

Open
opened 2026-04-13 10:32:13 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8814

State: open
Merged: No


Summary

This adds optional OAuth endpoint overrides for social providers so local emulators, sandbox environments, and custom OAuth servers can be used without changing provider defaults.

Closes

#8811

What changed

  • added optional provider config fields:
    • authorizationEndpoint
    • tokenEndpoint
    • userInfoEndpoint
    • jwksEndpoint
  • updated shared OAuth helpers to respect overridden token endpoints
  • updated social providers to prefer explicit endpoint overrides over derived/default URLs
  • preserved existing behavior when overrides are not provided
  • added coverage for:
    • Google auth/token/JWKS override flow
    • Railway token + userinfo override flow
    • GitLab explicit override precedence over issuer-derived endpoints
  • documented the new options in the reference docs

Why

Several social providers had hardcoded authorization, token, userinfo, or JWKS URLs, which made local OAuth emulator support difficult or impossible. This change enables emulator-based development and testing while keeping production defaults unchanged.


Summary by cubic

Add optional OAuth endpoint overrides for social providers to support local emulators, sandboxes, and custom OAuth servers. Overrides apply to authorization, token, refresh, user info, and JWKS calls; defaults remain when not set.

  • New Features
    • Most providers honor authorizationEndpoint, tokenEndpoint, userInfoEndpoint, and jwksEndpoint; WeChat adds refreshTokenEndpoint.
    • Core auth-code and refresh flows use options.tokenEndpoint; JWKS fetches use options.jwksEndpoint (Apple, Google, Cognito, Microsoft, Facebook).
    • Authorization URLs keep existing query params while adding required ones (Discord, TikTok, Roblox, Slack, Zoom, VK). GitLab prefers explicit overrides over issuer-derived URLs.
    • Provider tweaks: GitHub derives the email endpoint from a custom userInfoEndpoint; PayPal preserves query params on user info calls; more providers accept userInfoEndpoint overrides; Reddit honors tokenEndpoint. Tests expanded; docs include examples and option references.

Written for commit 6f387077e4590799d35bbabdc096bbf14e4b5795. Summary will update on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8814 **State:** open **Merged:** No --- ## Summary This adds optional OAuth endpoint overrides for social providers so local emulators, sandbox environments, and custom OAuth servers can be used without changing provider defaults. ## Closes #8811 ### What changed - added optional provider config fields: - `authorizationEndpoint` - `tokenEndpoint` - `userInfoEndpoint` - `jwksEndpoint` - updated shared OAuth helpers to respect overridden token endpoints - updated social providers to prefer explicit endpoint overrides over derived/default URLs - preserved existing behavior when overrides are not provided - added coverage for: - Google auth/token/JWKS override flow - Railway token + userinfo override flow - GitLab explicit override precedence over issuer-derived endpoints - documented the new options in the reference docs ## Why Several social providers had hardcoded authorization, token, userinfo, or JWKS URLs, which made local OAuth emulator support difficult or impossible. This change enables emulator-based development and testing while keeping production defaults unchanged. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add optional OAuth endpoint overrides for social providers to support local emulators, sandboxes, and custom OAuth servers. Overrides apply to authorization, token, refresh, user info, and JWKS calls; defaults remain when not set. - **New Features** - Most providers honor `authorizationEndpoint`, `tokenEndpoint`, `userInfoEndpoint`, and `jwksEndpoint`; WeChat adds `refreshTokenEndpoint`. - Core auth-code and refresh flows use `options.tokenEndpoint`; JWKS fetches use `options.jwksEndpoint` (Apple, Google, Cognito, Microsoft, Facebook). - Authorization URLs keep existing query params while adding required ones (Discord, TikTok, Roblox, Slack, Zoom, VK). GitLab prefers explicit overrides over issuer-derived URLs. - Provider tweaks: GitHub derives the email endpoint from a custom `userInfoEndpoint`; PayPal preserves query params on user info calls; more providers accept `userInfoEndpoint` overrides; Reddit honors `tokenEndpoint`. Tests expanded; docs include examples and option references. <sup>Written for commit 6f387077e4590799d35bbabdc096bbf14e4b5795. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 10:32:13 -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#16477