[PR #4829] [MERGED] feat: awaitable social provider config #13849

Closed
opened 2026-04-13 09:10:49 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4829
Author: @dvanmali
Created: 9/23/2025
Status: Merged
Merged: 2/4/2026
Merged by: @himself65

Base: canaryHead: clientSecret


📝 Commits (4)

📊 Changes

21 files changed (+350 additions, -159 deletions)

View changed files

📝 packages/better-auth/src/api/routes/account.ts (+23 -23)
📝 packages/better-auth/src/api/routes/callback.ts (+5 -3)
📝 packages/better-auth/src/api/routes/sign-in.ts (+4 -3)
📝 packages/better-auth/src/context/create-context.test.ts (+26 -8)
📝 packages/better-auth/src/context/create-context.ts (+29 -23)
📝 packages/better-auth/src/context/helpers.ts (+14 -0)
📝 packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.ts (+5 -1)
📝 packages/better-auth/src/plugins/one-tap/index.ts (+5 -3)
📝 packages/better-auth/src/social.test.ts (+79 -45)
📝 packages/cli/src/commands/generate.ts (+11 -5)
📝 packages/cli/src/commands/migrate.ts (+12 -6)
📝 packages/core/src/oauth2/client-credentials-token.ts (+26 -2)
📝 packages/core/src/oauth2/create-authorization-url.ts (+3 -1)
📝 packages/core/src/oauth2/index.ts (+3 -0)
📝 packages/core/src/oauth2/refresh-access-token.ts (+29 -2)
📝 packages/core/src/oauth2/validate-authorization-code.ts (+42 -3)
📝 packages/core/src/social-providers/apple.ts (+1 -5)
📝 packages/core/src/social-providers/index.ts (+6 -5)
📝 packages/core/src/types/helper.ts (+1 -0)
📝 packages/telemetry/src/detectors/detect-auth-config.ts (+25 -20)

...and 1 more files

📄 Description

Allows awaitable configuration for social providers. Fetches options at initialization to check for population of specific fields and per request. Useful for clients with expirable secrets such as Apple and other dynamically registered clients that utilize non-zero client_secret_expires_at as specified in RFC 7591.

Suggestion:

Fixes:


Summary by cubic

Adds awaitable social provider config so providers and OAuth options can be resolved at runtime. This improves support for rotating/expiring secrets and dynamic clients across all OAuth flows.

  • New Features

    • SocialProviders entries now accept a config object or () => Promise.
    • ProviderOptions (including clientSecret) is awaitable in authorization URL, authorization code, refresh token, and client credentials flows.
    • Added async request helpers: authorizationCodeRequest, refreshAccessTokenRequest, clientCredentialsTokenRequest.
    • Added getAwaitableValue helper and updated endpoints/plugins to resolve provider configs on demand. Apple provider and telemetry detection updated to use async config.
  • Migration

    • Prefer the new async request helpers listed above; the existing create* functions remain for backward compatibility but are deprecated.
    • If you access social provider config directly, it may be a function; handle resolving it asynchronously.

Written for commit 15c5e1ce26. Summary will update 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/4829 **Author:** [@dvanmali](https://github.com/dvanmali) **Created:** 9/23/2025 **Status:** ✅ Merged **Merged:** 2/4/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `clientSecret` --- ### 📝 Commits (4) - [`5ce3ae9`](https://github.com/better-auth/better-auth/commit/5ce3ae9e6a0a7327366ac250d202216fb43b7dfd) feat: async config - [`3f5d321`](https://github.com/better-auth/better-auth/commit/3f5d3217512191b13394a13704a15a26a6641e5b) style: lintfix - [`795709e`](https://github.com/better-auth/better-auth/commit/795709e145ad16bfb15f69415e76470ff057d16c) fix: cubic suggestions - [`15c5e1c`](https://github.com/better-auth/better-auth/commit/15c5e1ce26ae5d43eef807d07cb00d4e433e3e1b) fix: make backwards compatible ### 📊 Changes **21 files changed** (+350 additions, -159 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/account.ts` (+23 -23) 📝 `packages/better-auth/src/api/routes/callback.ts` (+5 -3) 📝 `packages/better-auth/src/api/routes/sign-in.ts` (+4 -3) 📝 `packages/better-auth/src/context/create-context.test.ts` (+26 -8) 📝 `packages/better-auth/src/context/create-context.ts` (+29 -23) 📝 `packages/better-auth/src/context/helpers.ts` (+14 -0) 📝 `packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.ts` (+5 -1) 📝 `packages/better-auth/src/plugins/one-tap/index.ts` (+5 -3) 📝 `packages/better-auth/src/social.test.ts` (+79 -45) 📝 `packages/cli/src/commands/generate.ts` (+11 -5) 📝 `packages/cli/src/commands/migrate.ts` (+12 -6) 📝 `packages/core/src/oauth2/client-credentials-token.ts` (+26 -2) 📝 `packages/core/src/oauth2/create-authorization-url.ts` (+3 -1) 📝 `packages/core/src/oauth2/index.ts` (+3 -0) 📝 `packages/core/src/oauth2/refresh-access-token.ts` (+29 -2) 📝 `packages/core/src/oauth2/validate-authorization-code.ts` (+42 -3) 📝 `packages/core/src/social-providers/apple.ts` (+1 -5) 📝 `packages/core/src/social-providers/index.ts` (+6 -5) 📝 `packages/core/src/types/helper.ts` (+1 -0) 📝 `packages/telemetry/src/detectors/detect-auth-config.ts` (+25 -20) _...and 1 more files_ </details> ### 📄 Description Allows awaitable configuration for social providers. Fetches options at initialization to check for population of specific fields and per request. Useful for clients with expirable secrets such as [Apple](https://developer.apple.com/documentation/accountorganizationaldatasharing/creating-a-client-secret) and other dynamically registered clients that utilize non-zero `client_secret_expires_at` as specified in [RFC 7591](https://datatracker.ietf.org/doc/html/rfc7591#section-3.2.1). Suggestion: - [x] #4699 Fixes: - [x] #1522 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds awaitable social provider config so providers and OAuth options can be resolved at runtime. This improves support for rotating/expiring secrets and dynamic clients across all OAuth flows. - **New Features** - SocialProviders entries now accept a config object or () => Promise<config>. - ProviderOptions (including clientSecret) is awaitable in authorization URL, authorization code, refresh token, and client credentials flows. - Added async request helpers: authorizationCodeRequest, refreshAccessTokenRequest, clientCredentialsTokenRequest. - Added getAwaitableValue helper and updated endpoints/plugins to resolve provider configs on demand. Apple provider and telemetry detection updated to use async config. - **Migration** - Prefer the new async request helpers listed above; the existing create* functions remain for backward compatibility but are deprecated. - If you access social provider config directly, it may be a function; handle resolving it asynchronously. <sup>Written for commit 15c5e1ce26ae5d43eef807d07cb00d4e433e3e1b. Summary will update 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-04-13 09:10:49 -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#13849