[GH-ISSUE #4333] How to issue oidc access token? #18532

Closed
opened 2026-04-15 17:01:54 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @auroradanier on GitHub (Aug 31, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4333

According to the doc, there is an oauth access token table exist, but I don't see any method to generate the token. I had to write my own oauth2/token endpoint to issue token. But is this the correct way? or betterauth has some other method to generate token that I'm not aware of?

Thanks!

OAuth Access Token

Originally created by @auroradanier on GitHub (Aug 31, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4333 According to the doc, there is an oauth access token table exist, but I don't see any method to generate the token. I had to write my own oauth2/token endpoint to issue token. But is this the correct way? or betterauth has some other method to generate token that I'm not aware of? Thanks! [OAuth Access Token](https://www.better-auth.com/docs/plugins/oidc-provider#oauth-access-token)
GiteaMirror added the locked label 2026-04-15 17:01:54 -05:00
Author
Owner

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

Hi @auroradanier! I'm Dosu and I’m helping the better-auth team.

Better Auth provides a built-in /oauth2/token endpoint as part of the OIDC provider plugin for issuing access tokens. You don't need to implement your own token endpoint—just use the standard OAuth2 flow with this endpoint. It handles both authorization code and refresh token grants, validates credentials, and generates/stores access and refresh tokens in the oauthAccessToken table. If you enable the JWT plugin, ID tokens are signed securely as well. For most use cases, integrating your client apps with the built-in OAuth2 endpoints is the recommended approach. You can find the implementation details in the codebase and docs: see here.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3240193096 --> @dosubot[bot] commented on GitHub (Aug 31, 2025): <!-- Greeting --> Hi @auroradanier! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> Better Auth provides a built-in `/oauth2/token` endpoint as part of the OIDC provider plugin for issuing access tokens. You don't need to implement your own token endpoint—just use the standard OAuth2 flow with this endpoint. It handles both authorization code and refresh token grants, validates credentials, and generates/stores access and refresh tokens in the `oauthAccessToken` table. If you enable the JWT plugin, ID tokens are signed securely as well. For most use cases, integrating your client apps with the built-in OAuth2 endpoints is the recommended approach. You can find the implementation details in the codebase and docs: [see here](https://github.com/better-auth/better-auth/blob/cf7f2f118147b6a79a99fcf48898408f038390f5/packages/better-auth/src/plugins/oidc-provider/index.ts). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/6123b179-673b-4f0c-8319-032b9c5e03e9?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/6123b179-673b-4f0c-8319-032b9c5e03e9?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/6123b179-673b-4f0c-8319-032b9c5e03e9?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/6123b179-673b-4f0c-8319-032b9c5e03e9?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6123b179-673b-4f0c-8319-032b9c5e03e9?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/6123b179-673b-4f0c-8319-032b9c5e03e9?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/6123b179-673b-4f0c-8319-032b9c5e03e9?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4333)
Author
Owner

@auroradanier commented on GitHub (Sep 1, 2025):

@dosu seems current config for grant method only work with auth flow, so does it support implict, password or client flow? how to set it?

<!-- gh-comment-id:3241180739 --> @auroradanier commented on GitHub (Sep 1, 2025): @dosu seems current config for grant method only work with auth flow, so does it support implict, password or client flow? how to set it?
Author
Owner

@dosubot[bot] commented on GitHub (Sep 1, 2025):

Better Auth’s OIDC provider plugin only supports the authorization_code and refresh_token grant types out of the box. The /oauth2/token endpoint will reject any other grant_type (like implicit, password, or client_credentials) with an unsupported_grant_type error, even if you configure those grant types during client registration or in trustedClients. This means you cannot use implicit, password, or client credentials flows directly with the built-in token endpoint (source).

If you need support for other grant types, you’d have to extend the plugin or implement custom endpoints. The documentation lists those grant types as configurable, but the code only implements authorization_code and refresh_token (source). For client credentials, there are helper utilities in the codebase, but the OIDC provider’s token endpoint does not handle it (source).

Let me know if you want details on how to extend the plugin or set up a custom flow!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3241190800 --> @dosubot[bot] commented on GitHub (Sep 1, 2025): <!-- Answer --> Better Auth’s OIDC provider plugin only supports the authorization_code and refresh_token grant types out of the box. The /oauth2/token endpoint will reject any other grant_type (like implicit, password, or client_credentials) with an unsupported_grant_type error, even if you configure those grant types during client registration or in trustedClients. This means you cannot use implicit, password, or client credentials flows directly with the built-in token endpoint ([source](https://github.com/better-auth/better-auth/blob/cf7f2f118147b6a79a99fcf48898408f038390f5/packages/better-auth/src/plugins/oidc-provider/index.ts)). If you need support for other grant types, you’d have to extend the plugin or implement custom endpoints. The documentation lists those grant types as configurable, but the code only implements authorization_code and refresh_token ([source](https://github.com/better-auth/better-auth/blob/cf7f2f118147b6a79a99fcf48898408f038390f5/docs/content/docs/plugins/oidc-provider.mdx)). For client credentials, there are helper utilities in the codebase, but the OIDC provider’s token endpoint does not handle it ([source](https://github.com/better-auth/better-auth/pull/4085)). Let me know if you want details on how to extend the plugin or set up a custom flow! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/3346b294-bb2c-4c20-bf04-dc2926359adb?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3346b294-bb2c-4c20-bf04-dc2926359adb?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3346b294-bb2c-4c20-bf04-dc2926359adb?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3346b294-bb2c-4c20-bf04-dc2926359adb?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3346b294-bb2c-4c20-bf04-dc2926359adb?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3346b294-bb2c-4c20-bf04-dc2926359adb?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3346b294-bb2c-4c20-bf04-dc2926359adb?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4333)
Author
Owner

@auroradanier commented on GitHub (Sep 1, 2025):

@dosu for the mcp plugin, does it support trusted client as in the oauth2 endpoints? seems trusted client doesn't work.

<!-- gh-comment-id:3241659475 --> @auroradanier commented on GitHub (Sep 1, 2025): @dosu for the mcp plugin, does it support trusted client as in the oauth2 endpoints? seems trusted client doesn't work.
Author
Owner

@dosubot[bot] commented on GitHub (Sep 1, 2025):

The MCP plugin does not currently support trusted clients in the same way as the OAuth2 endpoints or the OIDC provider plugin. MCP always validates clients via database lookups and enforces client_secret checks for confidential clients and PKCE for public clients—there’s no config option to bypass these checks or skip consent for trusted clients (source).

There is an open PR that proposes adding trusted client support to MCP, but it’s not yet merged or available in the main codebase (source). For now, if you need trusted client-like behavior, you’ll need to register clients as confidential or public and use the standard authentication flows.

Let me know if you want details on MCP client registration or want to track the trusted client feature as it develops!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3241671396 --> @dosubot[bot] commented on GitHub (Sep 1, 2025): <!-- Answer --> The MCP plugin does not currently support trusted clients in the same way as the OAuth2 endpoints or the OIDC provider plugin. MCP always validates clients via database lookups and enforces client_secret checks for confidential clients and PKCE for public clients—there’s no config option to bypass these checks or skip consent for trusted clients ([source](https://github.com/better-auth/better-auth/blob/cf7f2f118147b6a79a99fcf48898408f038390f5/packages/better-auth/src/plugins/mcp/index.ts)). There is an open PR that proposes adding trusted client support to MCP, but it’s not yet merged or available in the main codebase ([source](https://github.com/better-auth/better-auth/pull/4057)). For now, if you need trusted client-like behavior, you’ll need to register clients as confidential or public and use the standard authentication flows. Let me know if you want details on MCP client registration or want to track the trusted client feature as it develops! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/3013a9c2-12ac-4a2d-89ee-3cabc4a2a482?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3013a9c2-12ac-4a2d-89ee-3cabc4a2a482?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3013a9c2-12ac-4a2d-89ee-3cabc4a2a482?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3013a9c2-12ac-4a2d-89ee-3cabc4a2a482?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3013a9c2-12ac-4a2d-89ee-3cabc4a2a482?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3013a9c2-12ac-4a2d-89ee-3cabc4a2a482?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3013a9c2-12ac-4a2d-89ee-3cabc4a2a482?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4333)
Author
Owner

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

Closing as access tokens are supported. If you are looking for JWT access tokens, there's a separate issue

<!-- gh-comment-id:3330761057 --> @dvanmali commented on GitHub (Sep 24, 2025): Closing as access tokens are supported. If you are looking for JWT access tokens, there's a [separate issue](https://github.com/better-auth/better-auth/issues/4268)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18532