OIDC Client Registration Error? #1854

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

Originally created by @rahinkore on GitHub (Sep 5, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Try creating an OIDC Client

Current vs. Expected behavior

I ran this code:

      const fetchResponse = await auth.api.registerOAuthApplication({
        body: {
          client_name: "MY CLIENT NAME",
          redirect_uris: ["https://MYWEBSITE.com/api/auth/game-login-callback", "http://localhost:3000/api/auth/game-login-callback"],
          token_endpoint_auth_method: "client_secret_post",
          grant_types: ["password", "refresh_token", "authorization_code", "client_credentials"], // Support password grant for game login
          response_types: ["code", "token"],
          scope: "openid profile email",
          client_uri: "https://MYWEBSITE.com",
          metadata: {
            game_client: true,
            trusted: true
          },
          
        },
        asResponse: true
      })

In an api route

But it returned

Authentication required for client registration

what authentication?

I read the documents in better auth.

What version of Better Auth are you using?

1.3.7 I think

System info

bunx @better-auth/cli info   

    
Usage: better-auth [options] [command]

Better Auth CLI

Options:
  -V, --version       output the version number
  -h, --help          display help for command 

Commands:
  init [options]
  migrate [options]
  generate [options]
  secret

Which area(s) are affected? (Select all that apply)

Other

Auth config (if applicable)


Additional context

No response

Originally created by @rahinkore on GitHub (Sep 5, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Try creating an OIDC Client ### Current vs. Expected behavior I ran this code: ``` const fetchResponse = await auth.api.registerOAuthApplication({ body: { client_name: "MY CLIENT NAME", redirect_uris: ["https://MYWEBSITE.com/api/auth/game-login-callback", "http://localhost:3000/api/auth/game-login-callback"], token_endpoint_auth_method: "client_secret_post", grant_types: ["password", "refresh_token", "authorization_code", "client_credentials"], // Support password grant for game login response_types: ["code", "token"], scope: "openid profile email", client_uri: "https://MYWEBSITE.com", metadata: { game_client: true, trusted: true }, }, asResponse: true }) ``` In an api route But it returned Authentication required for client registration what authentication? I read the documents in better auth. ### What version of Better Auth are you using? 1.3.7 I think ### System info ```bash bunx @better-auth/cli info Usage: better-auth [options] [command] Better Auth CLI Options: -V, --version output the version number -h, --help display help for command Commands: init [options] migrate [options] generate [options] secret ``` ### Which area(s) are affected? (Select all that apply) Other ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 09:08:37 -05:00
Author
Owner

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

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

The "Authentication required for client registration" error means the Better Auth API expects your registration request to be authenticated—usually with a valid user session or token, often requiring admin privileges. By default, unauthenticated (public) client registration is not allowed for security reasons.

To resolve this, make sure your API route is called by an authenticated user. For example, if you're using this in a server-side context, ensure the request includes authentication headers or a session cookie from a signed-in admin user. Tests in the codebase confirm that registration only succeeds when the request is made with valid authentication headers from a signed-in user. If you want to allow unauthenticated dynamic client registration, you would need to customize the server's configuration, but this is not supported out of the box for security reasons see code and tests.

If you need more details on how to authenticate the request in your specific setup, let me know what authentication/session system you're using and I can help with concrete examples.

To reply, just mention @dosu.


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

@dosubot[bot] commented on GitHub (Sep 5, 2025): <!-- Greeting --> Hi @rahinkore! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> The "Authentication required for client registration" error means the Better Auth API expects your registration request to be authenticated—usually with a valid user session or token, often requiring admin privileges. By default, unauthenticated (public) client registration is not allowed for security reasons. To resolve this, make sure your API route is called by an authenticated user. For example, if you're using this in a server-side context, ensure the request includes authentication headers or a session cookie from a signed-in admin user. Tests in the codebase confirm that registration only succeeds when the request is made with valid authentication headers from a signed-in user. If you want to allow unauthenticated dynamic client registration, you would need to customize the server's configuration, but this is not supported out of the box for security reasons [see code and tests](https://github.com/better-auth/better-auth/pull/3416). If you need more details on how to authenticate the request in your specific setup, let me know what authentication/session system you're using and I can help with concrete examples. <!-- 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/f2c8e0dc-9271-4bbf-8c69-9d8b2d43888f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/f2c8e0dc-9271-4bbf-8c69-9d8b2d43888f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/f2c8e0dc-9271-4bbf-8c69-9d8b2d43888f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/f2c8e0dc-9271-4bbf-8c69-9d8b2d43888f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/f2c8e0dc-9271-4bbf-8c69-9d8b2d43888f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/f2c8e0dc-9271-4bbf-8c69-9d8b2d43888f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/f2c8e0dc-9271-4bbf-8c69-9d8b2d43888f?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/4461)
Author
Owner

@rahinkore commented on GitHub (Sep 5, 2025):

@dosu am I supposed to create a new client everytime someone wants to get their access token or I will do it once myself and use it from then onwards

@rahinkore commented on GitHub (Sep 5, 2025): @dosu am I supposed to create a new client everytime someone wants to get their access token or I will do it once myself and use it from then onwards
Author
Owner

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

You only need to register an OIDC client once per application—not for every user who needs an access token. After registering the client and getting its client_id (and client_secret, if applicable), your app uses those credentials to request tokens for any user who authenticates through it. This is the standard pattern for OIDC and OAuth2, and Better Auth follows this approach for security and manageability see docs and code.

If you have a special use case (like multi-tenant apps or dynamic client registration), you can enable dynamic registration, but even then, clients are registered per app, not per user. Let me know if you need details on advanced scenarios!

To reply, just mention @dosu.


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

@dosubot[bot] commented on GitHub (Sep 5, 2025): <!-- Answer --> You only need to register an OIDC client once per application—not for every user who needs an access token. After registering the client and getting its client_id (and client_secret, if applicable), your app uses those credentials to request tokens for any user who authenticates through it. This is the standard pattern for OIDC and OAuth2, and Better Auth follows this approach for security and manageability [see docs and code](https://github.com/better-auth/better-auth/blob/e812142c6cb91a65bba022b77f1176f7cca6dff2/docs/content/docs/plugins/oidc-provider.mdx). If you have a special use case (like multi-tenant apps or dynamic client registration), you can enable dynamic registration, but even then, clients are registered per app, not per user. Let me know if you need details on advanced scenarios! <!-- 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/30caad6a-91ff-406e-bde3-3f20730d454c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/30caad6a-91ff-406e-bde3-3f20730d454c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/30caad6a-91ff-406e-bde3-3f20730d454c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/30caad6a-91ff-406e-bde3-3f20730d454c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/30caad6a-91ff-406e-bde3-3f20730d454c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/30caad6a-91ff-406e-bde3-3f20730d454c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/30caad6a-91ff-406e-bde3-3f20730d454c?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/4461)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1854