[GH-ISSUE #1796] Expose GitHub OAuth access token in session #8920

Closed
opened 2026-04-13 04:10:05 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @ukanwat on GitHub (Mar 13, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1796

Is this suited for github?

  • Yes, this is suited for github

When integrating with GitHub API, Better Auth doesn't expose the GitHub OAuth access token in the session.
I am trying to integrate access to user's github repositories, tags, etc

Describe the solution you'd like

Add a way to access provider tokens either:

Through session: session.providers.github.accessToken
Via a dedicated method: getProviderToken('github')
With a config option: includeProviderTokens: true

Describe alternatives you've considered

Using Personal Access Tokens (not suitable for multi-user apps)

Additional context

No response

Originally created by @ukanwat on GitHub (Mar 13, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1796 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. When integrating with GitHub API, Better Auth doesn't expose the GitHub OAuth access token in the session. I am trying to integrate access to user's github repositories, tags, etc ### Describe the solution you'd like Add a way to access provider tokens either: Through session: session.providers.github.accessToken Via a dedicated method: getProviderToken('github') With a config option: includeProviderTokens: true ### Describe alternatives you've considered Using Personal Access Tokens (not suitable for multi-user apps) ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 04:10:05 -05:00
Author
Owner

@moshetanzer commented on GitHub (Mar 20, 2025):

Hey,

You can definitely do this by customising the session https://www.better-auth.com/docs/concepts/session-management#customizing-session-response not sure what use case is or if this is the safest/best way to do it though.

<!-- gh-comment-id:2741587011 --> @moshetanzer commented on GitHub (Mar 20, 2025): Hey, You can definitely do this by customising the session https://www.better-auth.com/docs/concepts/session-management#customizing-session-response not sure what use case is or if this is the safest/best way to do it though.
Author
Owner

@kevinehosford commented on GitHub (Apr 11, 2025):

I actually notice that the accessToken is not available in the params of that plugin. it's a different token.

<!-- gh-comment-id:2797095642 --> @kevinehosford commented on GitHub (Apr 11, 2025): I actually notice that the accessToken is not available in the params of that plugin. it's a different `token`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8920