[PR #6874] [MERGED] fix(generic-oauth): ensure encryptOAuthTokens is respected in account linking flow #6938

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6874
Author: @DevanAbinaya
Created: 12/19/2025
Status: Merged
Merged: 12/20/2025
Merged by: @himself65

Base: canaryHead: fix/account-linking-token-encryption


📝 Commits (6)

  • cc582db fix(generic-oauth): ensure token encryption is applied when linking accounts
  • db2d71a Merge branch 'better-auth:canary' into fix/account-linking-token-encryption
  • fd799c7 Merge branch 'better-auth:canary' into fix/account-linking-token-encryption
  • d389890 Merge branch 'canary' into fix/account-linking-token-encryption
  • e6fa9dd Merge branch 'canary' into fix/account-linking-token-encryption
  • 864826b Merge branch 'canary' into fix/account-linking-token-encryption

📊 Changes

1 file changed (+8 additions, -4 deletions)

View changed files

📝 packages/better-auth/src/plugins/generic-oauth/routes.ts (+8 -4)

📄 Description

It seems that this was skipped in https://github.com/better-auth/better-auth/pull/2552 resulting linking account to a genericOAuth account doesn't encrypt the tokens even when encryptOAuthTokens is set to true


Summary by cubic

Fixes generic OAuth account linking to respect encryptOAuthTokens. Access and refresh tokens are now encrypted during link/update flows by using setTokenUtil.

  • Bug Fixes
    • Apply setTokenUtil to accessToken and refreshToken in oAuth2Callback for both create and update paths.
    • Leaves idToken, scopes, and expiry fields unchanged.

Written for commit 864826b297. 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/6874 **Author:** [@DevanAbinaya](https://github.com/DevanAbinaya) **Created:** 12/19/2025 **Status:** ✅ Merged **Merged:** 12/20/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/account-linking-token-encryption` --- ### 📝 Commits (6) - [`cc582db`](https://github.com/better-auth/better-auth/commit/cc582db8fa87906bf9bd10ba2fc27e5cb5047735) fix(generic-oauth): ensure token encryption is applied when linking accounts - [`db2d71a`](https://github.com/better-auth/better-auth/commit/db2d71ac8982e84b523857f412bb4d6d6c799aff) Merge branch 'better-auth:canary' into fix/account-linking-token-encryption - [`fd799c7`](https://github.com/better-auth/better-auth/commit/fd799c7e44d65753c120030433f8c3fd5564e146) Merge branch 'better-auth:canary' into fix/account-linking-token-encryption - [`d389890`](https://github.com/better-auth/better-auth/commit/d389890958749e939bd83a6075ad60f98dc792b4) Merge branch 'canary' into fix/account-linking-token-encryption - [`e6fa9dd`](https://github.com/better-auth/better-auth/commit/e6fa9dd89025826c498817d408552019bcbe3dd4) Merge branch 'canary' into fix/account-linking-token-encryption - [`864826b`](https://github.com/better-auth/better-auth/commit/864826b2976c25a3da590e5f4b03ecb89a808ad8) Merge branch 'canary' into fix/account-linking-token-encryption ### 📊 Changes **1 file changed** (+8 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/generic-oauth/routes.ts` (+8 -4) </details> ### 📄 Description It seems that this was skipped in https://github.com/better-auth/better-auth/pull/2552 resulting linking account to a `genericOAuth` account doesn't encrypt the tokens even when `encryptOAuthTokens` is set to `true` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes generic OAuth account linking to respect encryptOAuthTokens. Access and refresh tokens are now encrypted during link/update flows by using setTokenUtil. - **Bug Fixes** - Apply setTokenUtil to accessToken and refreshToken in oAuth2Callback for both create and update paths. - Leaves idToken, scopes, and expiry fields unchanged. <sup>Written for commit 864826b2976c25a3da590e5f4b03ecb89a808ad8. 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-03-13 13:17: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#6938