[PR #6304] [CLOSED] fix: include refreshToken in getAccessToken response #23481

Closed
opened 2026-04-15 21:45:07 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6304
Author: @GautamBytes
Created: 11/25/2025
Status: Closed

Base: canaryHead: fix/get-access-token-fields


📝 Commits (1)

  • f560d05 fix(api): include refresh token in getAccessToken response

📊 Changes

1 file changed (+9 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/api/routes/account.ts (+9 -0)

📄 Description

Description

This PR addresses Issue #6301 where the getAccessToken endpoint was missing refreshToken and refreshTokenExpiresAt in the response body, specifically when running in stateless mode (though this logic applies generally).

The Fix

I located the return statement in packages/better-auth/src/api/routes/account.ts and noticed these fields were explicitly missing from the constructed response object, despite being defined in the Zod/OpenAPI schema for this endpoint.

I have updated the response to:

  1. Include refreshToken (decrypted using decryptOAuthToken, mirroring the accessToken logic).
  2. Include refreshTokenExpiresAt.

Fixes #6301


Summary by cubic

Return refreshToken and refreshTokenExpiresAt in getAccessToken responses to fix missing fields (notably in stateless mode) and align with the endpoint schema. refreshToken is decrypted like accessToken, and both fields fall back to newTokens or account values as available.

Written for commit f560d05f79. 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/6304 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 11/25/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/get-access-token-fields` --- ### 📝 Commits (1) - [`f560d05`](https://github.com/better-auth/better-auth/commit/f560d05f792aae031790270305be46781554a15a) fix(api): include refresh token in getAccessToken response ### 📊 Changes **1 file changed** (+9 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/account.ts` (+9 -0) </details> ### 📄 Description ## Description This PR addresses Issue #6301 where the `getAccessToken` endpoint was missing `refreshToken` and `refreshTokenExpiresAt` in the response body, specifically when running in stateless mode (though this logic applies generally). ## The Fix I located the return statement in `packages/better-auth/src/api/routes/account.ts` and noticed these fields were explicitly missing from the constructed response object, despite being defined in the Zod/OpenAPI schema for this endpoint. I have updated the response to: 1. Include `refreshToken` (decrypted using `decryptOAuthToken`, mirroring the `accessToken` logic). 2. Include `refreshTokenExpiresAt`. ## Related Issue Fixes #6301 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Return refreshToken and refreshTokenExpiresAt in getAccessToken responses to fix missing fields (notably in stateless mode) and align with the endpoint schema. refreshToken is decrypted like accessToken, and both fields fall back to newTokens or account values as available. <sup>Written for commit f560d05f792aae031790270305be46781554a15a. 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-04-15 21:45:07 -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#23481