[GH-ISSUE #4268] [OIDC] Allow access token to be a JWT #9879

Closed
opened 2026-04-13 05:40:42 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @julen on GitHub (Aug 27, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4268

Currently the OIDC plugin creates access tokens as an opaque string. This requires resource servers to query the authorization server DB in order to check for the existence/validity of the access token, and to further gather additional authorization info.

It'd be great if better-auth allowed defining OAuth access tokens as JWTs; such tokens would encode authorization information like expiry and scopes. This would allow resource servers to determine token validity and retrieve authorization information with no need to query DBs.

OIDC ID tokens are already encoded as a JWT, so it shouldn't take much additional effort to enable the same for access tokens.

Refs. https://auth0.com/blog/id-token-access-token-what-is-the-difference/

Image
Originally created by @julen on GitHub (Aug 27, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4268 Currently the OIDC plugin [creates access tokens as an opaque string](https://github.com/better-auth/better-auth/blob/3049ee9e8dabb27e8083060932af00bb7546d741/packages/better-auth/src/plugins/oidc-provider/index.ts#L581). This requires resource servers to query the authorization server DB in order to check for the existence/validity of the access token, and to further gather additional authorization info. It'd be great if better-auth allowed defining OAuth access tokens as JWTs; such tokens would encode authorization information like expiry and scopes. This would allow resource servers to determine token validity and retrieve authorization information with no need to query DBs. OIDC ID tokens are already encoded as a JWT, so it shouldn't take much additional effort to enable the same for access tokens. Refs. https://auth0.com/blog/id-token-access-token-what-is-the-difference/ <img width="1650" height="3551" alt="Image" src="https://github.com/user-attachments/assets/e2db4c56-8406-4777-b25d-79edaf931d73" />
GiteaMirror added the enhancementlocked labels 2026-04-13 05:40:42 -05:00
Author
Owner

@sypion commented on GitHub (Oct 28, 2025):

@julen did you ever figure out a workaround to this? Running into the same issue. Getting an opaque string instead of the full OAuth2 JWT.

<!-- gh-comment-id:3458314861 --> @sypion commented on GitHub (Oct 28, 2025): @julen did you ever figure out a workaround to this? Running into the same issue. Getting an opaque string instead of the full OAuth2 JWT.
Author
Owner

@julen commented on GitHub (Oct 28, 2025):

No workarounds on our side — we are waiting for the new OAuth 2.1 plugin in #4163 to be merged and released, which will fix this issue and allow the access token to be a JWT.

<!-- gh-comment-id:3458330566 --> @julen commented on GitHub (Oct 28, 2025): No workarounds on our side — we are waiting for the new OAuth 2.1 plugin in #4163 to be merged and released, which will fix this issue and allow the access token to be a JWT.
Author
Owner

@sypion commented on GitHub (Oct 28, 2025):

Thank you for the swift response. That PR will save us! A bit of a tricky block since we won't be able to continue development until we can get the JWT. Hopefully soon 🤞🏼

<!-- gh-comment-id:3458439496 --> @sypion commented on GitHub (Oct 28, 2025): Thank you for the swift response. That PR will save us! A bit of a tricky block since we won't be able to continue development until we can get the JWT. Hopefully soon 🤞🏼
Author
Owner

@dvanmali commented on GitHub (Dec 24, 2025):

Hi all, we released the new OAuth Provider Plugin which allows for JWT access tokens with the resource parameter describe in RFC 8707. Feel free to let us know how it works :)

<!-- gh-comment-id:3688540107 --> @dvanmali commented on GitHub (Dec 24, 2025): Hi all, we released the new [OAuth Provider Plugin](https://www.better-auth.com/docs/plugins/oauth-provider) which allows for JWT access tokens with the `resource` parameter describe in [RFC 8707](https://www.rfc-editor.org/rfc/rfc8707.html). Feel free to let us know how it works :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9879