[PR #4085] [MERGED] chore(oauth): separate betterFetch from request format #5178

Closed
opened 2026-03-13 12:13:05 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4085
Author: @dvanmali
Created: 8/19/2025
Status: Merged
Merged: 8/21/2025
Merged by: @Bekacru

Base: canaryHead: oauth2


📝 Commits (2)

  • 3f098ab feat: separate betterFetch from request format
  • c77dcf3 Merge branch 'better-auth:canary' into oauth2

📊 Changes

3 files changed (+198 additions, -16 deletions)

View changed files

packages/better-auth/src/oauth2/client-credentials-token.ts (+97 -0)
📝 packages/better-auth/src/oauth2/refresh-access-token.ts (+42 -7)
📝 packages/better-auth/src/oauth2/validate-authorization-code.ts (+59 -9)

📄 Description

Separates betterFetch from the actual request format needed for testing functions.

Adds a resource parameter to the function which has a specific format described by RFC 8707

Partial: #3458


Summary by cubic

Decoupled OAuth2 request construction from network calls and added RFC 8707 resource support across token flows. Improves testability and enables resource-scoped tokens. Partial: #3458.

  • New Features

    • Added resource (string | string[]) to authorization code, refresh token, and client credentials flows.
    • Introduced clientCredentialsToken and createClientCredentialsTokenRequest with Basic or form-post auth; maps expires_in to accessTokenExpiresAt.
  • Refactors

    • Added createAuthorizationCodeRequest and createRefreshAccessTokenRequest to return body + headers; betterFetch is used only in the caller.
    • refreshAccessToken now always sends grant_type=refresh_token (grantType param deprecated).

🔄 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/4085 **Author:** [@dvanmali](https://github.com/dvanmali) **Created:** 8/19/2025 **Status:** ✅ Merged **Merged:** 8/21/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `oauth2` --- ### 📝 Commits (2) - [`3f098ab`](https://github.com/better-auth/better-auth/commit/3f098ab25bb207389028a4a08974b7de972f880d) feat: separate betterFetch from request format - [`c77dcf3`](https://github.com/better-auth/better-auth/commit/c77dcf3bf87442d69255f7e9a446aa4dacba44fa) Merge branch 'better-auth:canary' into oauth2 ### 📊 Changes **3 files changed** (+198 additions, -16 deletions) <details> <summary>View changed files</summary> ➕ `packages/better-auth/src/oauth2/client-credentials-token.ts` (+97 -0) 📝 `packages/better-auth/src/oauth2/refresh-access-token.ts` (+42 -7) 📝 `packages/better-auth/src/oauth2/validate-authorization-code.ts` (+59 -9) </details> ### 📄 Description Separates betterFetch from the actual request format needed for testing functions. Adds a `resource` parameter to the function which has a specific format described by [RFC 8707](https://www.rfc-editor.org/rfc/rfc8707.html#name-authorization-request) Partial: #3458 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Decoupled OAuth2 request construction from network calls and added RFC 8707 resource support across token flows. Improves testability and enables resource-scoped tokens. Partial: #3458. - New Features - Added resource (string | string[]) to authorization code, refresh token, and client credentials flows. - Introduced clientCredentialsToken and createClientCredentialsTokenRequest with Basic or form-post auth; maps expires_in to accessTokenExpiresAt. - Refactors - Added createAuthorizationCodeRequest and createRefreshAccessTokenRequest to return body + headers; betterFetch is used only in the caller. - refreshAccessToken now always sends grant_type=refresh_token (grantType param deprecated). <!-- 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 12:13:05 -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#5178