Expose GitHub OAuth access token in session #837

Closed
opened 2026-03-13 08:06:31 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @ukanwat on GitHub (Mar 13, 2025).

Is this suited for github?

  • 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

Originally created by @ukanwat on GitHub (Mar 13, 2025). ### 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_
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.

@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.

@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#837