Feature Request: Implement Access Token Exposure and Automated Refresh for First-Party Application Support #736

Closed
opened 2026-03-13 08:02:11 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @jlzhjp on GitHub (Feb 24, 2025).

Is this suited for github?

  • Yes, this is suited for github

Currently, better-auth appears optimized for third-party OIDC authentication scenarios without native support as a first-party application. Critical features like access to the access token and automatic token refresh is absent from the implementation.

Describe the solution you'd like

  1. Programmatic access to the access token after authentication
  2. Automatic token refresh using stored refresh tokens
  3. Other optimizations for first-party application scenarios

This enhancement would position better-auth as a more versatile solution for both third-party and internal IAM use cases, particularly for organizations using self-hosted OIDC providers (Keycloak, etc.).

Describe alternatives you've considered

I tried using the Generic OAuth plugin, but it don't provide ways to get access tokens or handle automatic refreshes. This makes it hard to manage tokens and access resource server. Right now, I have to manually fetch tokens from the database and refresh them myself.

Additional context

Related Issue: https://github.com/better-auth/better-auth/issues/1488

Reference: Next.js Auth0 SDK
While Auth0's implementation is exclusive to their platform, similar patterns could make better-auth compatible with any OIDC provider

Originally created by @jlzhjp on GitHub (Feb 24, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Currently, `better-auth` appears optimized for third-party OIDC authentication scenarios without native support as a [first-party application](https://auth0.com/docs/get-started/applications/confidential-and-public-applications/first-party-and-third-party-applications). Critical features like access to the access token and automatic token refresh is absent from the implementation. ### Describe the solution you'd like 1. Programmatic access to the access token after authentication 2. Automatic token refresh using stored refresh tokens 3. Other optimizations for first-party application scenarios This enhancement would position better-auth as a more versatile solution for both third-party and internal IAM use cases, particularly for organizations using self-hosted OIDC providers (Keycloak, etc.). ### Describe alternatives you've considered I tried using the Generic OAuth plugin, but it don't provide ways to get access tokens or handle automatic refreshes. This makes it hard to manage tokens and access resource server. Right now, I have to manually fetch tokens from the database and refresh them myself. ### Additional context Related Issue: https://github.com/better-auth/better-auth/issues/1488 Reference: [Next.js Auth0 SDK](https://github.com/auth0/nextjs-auth0) While Auth0's implementation is exclusive to their platform, similar patterns could make `better-auth` compatible with any OIDC provider
Author
Owner

@alexandre-hallaine commented on GitHub (May 27, 2025):

I hope there is a day where it happened

@alexandre-hallaine commented on GitHub (May 27, 2025): I hope there is a day where it happened
Author
Owner

@dosubot[bot] commented on GitHub (Aug 26, 2025):

Hi, @jlzhjp. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested support for first-party applications in better-auth, specifically programmatic access to access tokens and automatic token refresh using stored refresh tokens.
  • This feature aims to improve better-auth's usability for internal IAM and self-hosted OIDC providers.
  • Current limitations require manual token management, which you find cumbersome.
  • You referenced Auth0's SDK as a model for this functionality.
  • The maintainer expressed hope for this feature in the future, and another user showed positive interest.

Next Steps:

  • Please let me know if this feature request is still relevant to the latest version of better-auth by commenting on this issue.
  • If I do not hear back within 7 days, I will automatically close this issue.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 26, 2025): Hi, @jlzhjp. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested support for first-party applications in better-auth, specifically programmatic access to access tokens and automatic token refresh using stored refresh tokens. - This feature aims to improve better-auth's usability for internal IAM and self-hosted OIDC providers. - Current limitations require manual token management, which you find cumbersome. - You referenced Auth0's SDK as a model for this functionality. - The maintainer expressed hope for this feature in the future, and another user showed positive interest. **Next Steps:** - Please let me know if this feature request is still relevant to the latest version of better-auth by commenting on this issue. - If I do not hear back within 7 days, I will automatically close this issue. Thank you for your understanding and contribution!
Author
Owner

@alexandre-hallaine commented on GitHub (Sep 3, 2025):

:/

@alexandre-hallaine commented on GitHub (Sep 3, 2025): :/
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#736