how to setup an genericOAuth provider #2261

Closed
opened 2026-03-13 09:39:22 -05:00 by GiteaMirror · 14 comments
Owner

Originally created by @RobinWitzschke on GitHub (Nov 5, 2025).

Hey Folks,

im struggling with setting up an costum OAuth provider

this is my plugins field in auth.ts

plugins: [ anonymous(), genericOAuth({ config: [ { providerId: "autodesk", clientId: process.env.AUTODESK_CLIENT_ID as string, clientSecret: process.env.AUTODESK_CLIENT_SECRET as string, discoveryUrl: "https://developer.api.autodesk.com/.well-known/openid-configuration", scopes: ["data:read"], }, ], }), ],

and I also importet the genericOAuthClient Plugin in the client.tsx (see below)

`export const authClient = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_APP_URL!,
basePath: "/api/auth",
plugins: [nextCookies(), anonymousClient(), genericOAuthClient()],
});

export const { signIn, signOut, signUp, useSession } = authClient;
`
When i know try to login via my Sign In form

and the generic handler

const handleGenericSocialSignIn = async () => { try { const { data, error } = await authClient.signIn.oauth2({ providerId: "autodesk", callbackURL: "/ms-callback", scopes: ["data:read"], }); console.log(data); } catch (error) {} };
nothing happens I see in the logs of next.js that

GET /en/sign-in? 200 in 207ms (compile: 20ms, proxy.ts: 142ms, render: 44ms)

can anyone help?

Originally created by @RobinWitzschke on GitHub (Nov 5, 2025). Hey Folks, im struggling with setting up an costum OAuth provider this is my plugins field in auth.ts `plugins: [ anonymous(), genericOAuth({ config: [ { providerId: "autodesk", clientId: process.env.AUTODESK_CLIENT_ID as string, clientSecret: process.env.AUTODESK_CLIENT_SECRET as string, discoveryUrl: "https://developer.api.autodesk.com/.well-known/openid-configuration", scopes: ["data:read"], }, ], }), ],` and I also importet the genericOAuthClient Plugin in the client.tsx (see below) `export const authClient = createAuthClient({ baseURL: process.env.NEXT_PUBLIC_APP_URL!, basePath: "/api/auth", plugins: [nextCookies(), anonymousClient(), genericOAuthClient()], }); export const { signIn, signOut, signUp, useSession } = authClient; ` When i know try to login via my Sign In form and the generic handler `const handleGenericSocialSignIn = async () => { try { const { data, error } = await authClient.signIn.oauth2({ providerId: "autodesk", callbackURL: "/ms-callback", scopes: ["data:read"], }); console.log(data); } catch (error) {} }; ` nothing happens I see in the logs of next.js that `GET /en/sign-in? 200 in 207ms (compile: 20ms, proxy.ts: 142ms, render: 44ms)` can anyone help?
GiteaMirror added the nextjssocial-provider labels 2026-03-13 09:39:22 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 5, 2025):

tag @better-auth-agent if you would like an answer from the Agent

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Nov 5, 2025): tag @better-auth-agent if you would like an answer from the Agent <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@RobinWitzschke commented on GitHub (Nov 5, 2025):

Sure @better-auth-agent

@RobinWitzschke commented on GitHub (Nov 5, 2025): Sure @better-auth-agent
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 5, 2025):

Hi there, thanks for reaching out! Your configuration for the genericOAuth provider looks similar to our documented examples. Here are a few troubleshooting steps to consider:

• Verify that your discoveryUrl ("https://developer.api.autodesk.com/.well-known/openid-configuration") returns the correct endpoints (authorization, token, etc.) that the provider expects. If it doesn’t, you may need to set those URLs explicitly in your configuration [1].

• Double-check that your environment variables (AUTODESK_CLIENT_ID and AUTODESK_CLIENT_SECRET) are correctly set and accessible to your build/runtime. Misconfigurations there can prevent the sign-in flow from proceeding.

• Ensure that your callbackURL ("/ms-callback") is properly configured and matches the redirect URI registered with Autodesk. Any mismatch might result in the authentication not triggering as expected [2].

• Since nothing happens in your logs, it might help to add error logging in your catch block of the sign-in function to see if any errors are being thrown silently. Sometimes the client sends back an error that isn’t immediately visible in the browser log.

• Confirm that the genericOAuthClient is properly imported and available in your client configuration, as both server- and client-side setups need to align.

Would you mind checking these details? Also, are there any network errors or messages visible in your browser’s developer console during the sign-in attempt? Tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Nov 5, 2025): Hi there, thanks for reaching out! Your configuration for the genericOAuth provider looks similar to our documented examples. Here are a few troubleshooting steps to consider: • Verify that your discoveryUrl ("https://developer.api.autodesk.com/.well-known/openid-configuration") returns the correct endpoints (authorization, token, etc.) that the provider expects. If it doesn’t, you may need to set those URLs explicitly in your configuration [[1]](https://www.better-auth.com/docs/authentication/other-social-providers). • Double-check that your environment variables (AUTODESK_CLIENT_ID and AUTODESK_CLIENT_SECRET) are correctly set and accessible to your build/runtime. Misconfigurations there can prevent the sign-in flow from proceeding. • Ensure that your callbackURL ("/ms-callback") is properly configured and matches the redirect URI registered with Autodesk. Any mismatch might result in the authentication not triggering as expected [[2]](https://www.better-auth.com/docs/reference/contributing). • Since nothing happens in your logs, it might help to add error logging in your catch block of the sign-in function to see if any errors are being thrown silently. Sometimes the client sends back an error that isn’t immediately visible in the browser log. • Confirm that the genericOAuthClient is properly imported and available in your client configuration, as both server- and client-side setups need to align. Would you mind checking these details? Also, are there any network errors or messages visible in your browser’s developer console during the sign-in attempt? Tag @better-auth-agent if you would like an answer from the Agent. <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@RobinWitzschke commented on GitHub (Nov 5, 2025):

so thats what the discoveryUrl endpoints returns

{ "issuer": "https://developer.api.autodesk.com", "authorization_endpoint": "https://developer.api.autodesk.com/authentication/v2/authorize", "token_endpoint": "https://developer.api.autodesk.com/authentication/v2/token", "userinfo_endpoint": "https://api.userprofile.autodesk.com/userinfo", "jwks_uri": "https://developer.api.autodesk.com/authentication/v2/keys", "revocation_endpoint": "https://developer.api.autodesk.com/authentication/v2/revoke", "introspection_endpoint": "https://developer.api.autodesk.com/authentication/v2/introspect", "scopes_supported": [ "user-profile:read", "user:read", "user:write", "viewables:read", "data:read", "data:write", "data:create", "data:search", "bucket:create", "bucket:read", "bucket:update", "bucket:delete", "code:all", "account:read", "account:write", "openid" ], "response_types_supported": [ "code", "code id_token", "id_token" ], "response_modes_supported": [ "fragment", "form_post", "query" ], "grant_types_supported": [ "authorization_code", "client_credentials", "refresh_token" ], "subject_types_supported": [ "public" ], "id_token_signing_alg_values_supported": [ "RS256" ], "token_endpoint_auth_methods_supported": [ "client_secret_basic", "client_secret_post" ], "code_challenge_methods_supported": [ "S256" ] }

@RobinWitzschke commented on GitHub (Nov 5, 2025): so thats what the discoveryUrl endpoints returns `{ "issuer": "https://developer.api.autodesk.com", "authorization_endpoint": "https://developer.api.autodesk.com/authentication/v2/authorize", "token_endpoint": "https://developer.api.autodesk.com/authentication/v2/token", "userinfo_endpoint": "https://api.userprofile.autodesk.com/userinfo", "jwks_uri": "https://developer.api.autodesk.com/authentication/v2/keys", "revocation_endpoint": "https://developer.api.autodesk.com/authentication/v2/revoke", "introspection_endpoint": "https://developer.api.autodesk.com/authentication/v2/introspect", "scopes_supported": [ "user-profile:read", "user:read", "user:write", "viewables:read", "data:read", "data:write", "data:create", "data:search", "bucket:create", "bucket:read", "bucket:update", "bucket:delete", "code:all", "account:read", "account:write", "openid" ], "response_types_supported": [ "code", "code id_token", "id_token" ], "response_modes_supported": [ "fragment", "form_post", "query" ], "grant_types_supported": [ "authorization_code", "client_credentials", "refresh_token" ], "subject_types_supported": [ "public" ], "id_token_signing_alg_values_supported": [ "RS256" ], "token_endpoint_auth_methods_supported": [ "client_secret_basic", "client_secret_post" ], "code_challenge_methods_supported": [ "S256" ] } `
Author
Owner

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

For genericOAuth to work with a custom provider like Autodesk, you need to explicitly set the authorizationUrl, tokenUrl, and userInfoUrl in your config, even if you provide a discoveryUrl. The plugin does not auto-populate these from the discovery document, so leaving them out can cause the OAuth flow to silently fail or do nothing reference.

Here's how you can update your config (you can get these endpoint URLs from Autodesk's OpenID configuration at https://developer.api.autodesk.com/.well-known/openid-configuration):

plugins: [
  anonymous(),
  genericOAuth({
    config: [
      {
        providerId: "autodesk",
        clientId: process.env.AUTODESK_CLIENT_ID as string,
        clientSecret: process.env.AUTODESK_CLIENT_SECRET as string,
        discoveryUrl: "https://developer.api.autodesk.com/.well-known/openid-configuration",
        authorizationUrl: "https://developer.api.autodesk.com/authentication/v1/authorize",
        tokenUrl: "https://developer.api.autodesk.com/authentication/v1/gettoken",
        userInfoUrl: "https://developer.api.autodesk.com/userprofile/v1/users/@me",
        scopes: ["data:read", "openid", "profile", "email"], // adjust as needed
      },
    ],
  }),
]

Make sure your Autodesk app's redirect URI matches the one Better Auth uses (by default: /api/auth/oauth2/callback/autodesk), and that your environment variables are set correctly.

If you still see nothing happening, check your server logs for errors about missing endpoints or invalid configuration. Also, ensure your sign-in handler is calling authClient.signIn.oauth2 with the correct providerId and callbackURL.

More details and working examples are in the genericOAuth plugin source and test suite.

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 (Nov 5, 2025): <!-- Answer --> For genericOAuth to work with a custom provider like Autodesk, you need to explicitly set the `authorizationUrl`, `tokenUrl`, and `userInfoUrl` in your config, even if you provide a `discoveryUrl`. The plugin does not auto-populate these from the discovery document, so leaving them out can cause the OAuth flow to silently fail or do nothing [reference](https://github.com/better-auth/better-auth/issues/3278). Here's how you can update your config (you can get these endpoint URLs from Autodesk's OpenID configuration at https://developer.api.autodesk.com/.well-known/openid-configuration): ```ts plugins: [ anonymous(), genericOAuth({ config: [ { providerId: "autodesk", clientId: process.env.AUTODESK_CLIENT_ID as string, clientSecret: process.env.AUTODESK_CLIENT_SECRET as string, discoveryUrl: "https://developer.api.autodesk.com/.well-known/openid-configuration", authorizationUrl: "https://developer.api.autodesk.com/authentication/v1/authorize", tokenUrl: "https://developer.api.autodesk.com/authentication/v1/gettoken", userInfoUrl: "https://developer.api.autodesk.com/userprofile/v1/users/@me", scopes: ["data:read", "openid", "profile", "email"], // adjust as needed }, ], }), ] ``` Make sure your Autodesk app's redirect URI matches the one Better Auth uses (by default: `/api/auth/oauth2/callback/autodesk`), and that your environment variables are set correctly. If you still see nothing happening, check your server logs for errors about missing endpoints or invalid configuration. Also, ensure your sign-in handler is calling `authClient.signIn.oauth2` with the correct providerId and callbackURL. More details and working examples are in the [genericOAuth plugin source](https://github.com/better-auth/better-auth/blob/7e6106707539ec9a8510c02cc84ac2e9c2d88db0/packages/better-auth/src/plugins/generic-oauth/index.ts) and [test suite](https://github.com/better-auth/better-auth/blob/7e6106707539ec9a8510c02cc84ac2e9c2d88db0/packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.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/59634779-04a0-4b63-a7ed-593da5c66164?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/59634779-04a0-4b63-a7ed-593da5c66164?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/59634779-04a0-4b63-a7ed-593da5c66164?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/59634779-04a0-4b63-a7ed-593da5c66164?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/59634779-04a0-4b63-a7ed-593da5c66164?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/59634779-04a0-4b63-a7ed-593da5c66164?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/59634779-04a0-4b63-a7ed-593da5c66164?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/5773)
Author
Owner

@RobinWitzschke commented on GitHub (Nov 5, 2025):

So I've added the meta data to my auth.ts

plugins: [ anonymous(), genericOAuth({ config: [ { providerId: "autodesk", clientId: process.env.AUTODESK_CLIENT_ID as string, clientSecret: process.env.AUTODESK_CLIENT_SECRET as string, discoveryUrl: "https://developer.api.autodesk.com/.well-known/openid-configuration", authorizationUrl: "https://developer.api.autodesk.com/authentication/v2/authorize", tokenUrl: "https://developer.api.autodesk.com/authentication/v2/token", userInfoUrl: "https://api.userprofile.autodesk.com/userinfo", scopes: ["data:read"], }, ], }), ],

and also added the redirect URI's at my Autodesk App

http://localhost:3000/api/auth/oauth2/callback/autodesk and http://localhost:3000/api/auth/callback/autodesk

what callback url do I have to add in my await authClient.signIn.oauth2({ providerId: "autodesk", callbackURL: "/ms-callback", scopes: ["data:read"], });

call? the one of my app or the one that the auth api is calling? should I try to rotate this to '/api/auth/oauth2/callback/autodesk'

any more suggestions how to debug and fix?

@dosu @better-auth-agent

@RobinWitzschke commented on GitHub (Nov 5, 2025): So I've added the meta data to my auth.ts `plugins: [ anonymous(), genericOAuth({ config: [ { providerId: "autodesk", clientId: process.env.AUTODESK_CLIENT_ID as string, clientSecret: process.env.AUTODESK_CLIENT_SECRET as string, discoveryUrl: "https://developer.api.autodesk.com/.well-known/openid-configuration", authorizationUrl: "https://developer.api.autodesk.com/authentication/v2/authorize", tokenUrl: "https://developer.api.autodesk.com/authentication/v2/token", userInfoUrl: "https://api.userprofile.autodesk.com/userinfo", scopes: ["data:read"], }, ], }), ],` and also added the redirect URI's at my Autodesk App `http://localhost:3000/api/auth/oauth2/callback/autodesk` and `http://localhost:3000/api/auth/callback/autodesk` what callback url do I have to add in my `await authClient.signIn.oauth2({ providerId: "autodesk", callbackURL: "/ms-callback", scopes: ["data:read"], });` call? the one of my app or the one that the auth api is calling? should I try to rotate this to '/api/auth/oauth2/callback/autodesk' any more suggestions how to debug and fix? @dosu @better-auth-agent
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 5, 2025):

It looks like your sign-in function’s callbackURL should match the route that your auth API is exposing for the OAuth callback. In most examples, the callback URL provided for sign-in is the route set up on your backend that handles the OAuth2 callback—for instance, using the genericOAuth route like "/api/auth/oauth2/callback/autodesk". This ensures that once the provider (in your case, Autodesk) finishes the OAuth steps, the redirect goes directly into your auth API handler, which then processes the token exchange and user session.

To troubleshoot further, make sure that:
• The callback URL in your signIn.oauth2 call exactly matches the one registered in your app’s configuration (Autodesk Developer App settings).
• The callback route in your auth API (e.g. "/api/auth/oauth2/callback/autodesk") is properly configured in your auth.ts plugin setup.
• If you’re using an intermediary "ms-callback" page for extra handling, you need to ensure it eventually redirects to the proper auth callback URL.

Matching these URLs helps avoid confusion on whether the redirect target is from your app or the auth API. You can also enable additional logging or inspect network requests to ensure that the OAuth process is reaching the expected callback endpoint.

Does this help clarify the configuration, or do you have any other questions or issues you’d like to dive into further? Tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Nov 5, 2025): It looks like your sign-in function’s callbackURL should match the route that your auth API is exposing for the OAuth callback. In most examples, the callback URL provided for sign-in is the route set up on your backend that handles the OAuth2 callback—for instance, using the genericOAuth route like "/api/auth/oauth2/callback/autodesk". This ensures that once the provider (in your case, Autodesk) finishes the OAuth steps, the redirect goes directly into your auth API handler, which then processes the token exchange and user session. To troubleshoot further, make sure that: • The callback URL in your signIn.oauth2 call exactly matches the one registered in your app’s configuration (Autodesk Developer App settings). • The callback route in your auth API (e.g. "/api/auth/oauth2/callback/autodesk") is properly configured in your auth.ts plugin setup. • If you’re using an intermediary "ms-callback" page for extra handling, you need to ensure it eventually redirects to the proper auth callback URL. Matching these URLs helps avoid confusion on whether the redirect target is from your app or the auth API. You can also enable additional logging or inspect network requests to ensure that the OAuth process is reaching the expected callback endpoint. Does this help clarify the configuration, or do you have any other questions or issues you’d like to dive into further? Tag @better-auth-agent if you would like an answer from the Agent. <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

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

You should keep callbackURL in your signIn.oauth2 call as your desired frontend route (like /ms-callback or /dashboard). This is where users will be redirected after a successful login—not the backend OAuth callback URI. The backend OAuth callback (e.g., /api/auth/oauth2/callback/autodesk) is what you need to register with Autodesk and is handled internally by Better Auth during the OAuth flow reference.

For debugging: check your browser’s network tab to see if a redirect to Autodesk is triggered, inspect backend logs for errors, and make sure your authorizationUrl and tokenUrl are set correctly. If nothing happens, add error logging to your sign-in handler and verify that the backend callback endpoint is reachable. If the flow still doesn’t work, try to isolate whether the issue is with the frontend (no redirect) or backend (no response from Autodesk or error in callback handling).

Let me know if you see any errors or if the redirect isn’t happening—happy to help dig deeper!

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 (Nov 5, 2025): <!-- Answer --> You should keep callbackURL in your signIn.oauth2 call as your desired frontend route (like `/ms-callback` or `/dashboard`). This is where users will be redirected after a successful login—not the backend OAuth callback URI. The backend OAuth callback (e.g., `/api/auth/oauth2/callback/autodesk`) is what you need to register with Autodesk and is handled internally by Better Auth during the OAuth flow [reference](https://github.com/better-auth/better-auth/blob/7e6106707539ec9a8510c02cc84ac2e9c2d88db0/packages/better-auth/src/plugins/generic-oauth/index.ts#L224-L796). For debugging: check your browser’s network tab to see if a redirect to Autodesk is triggered, inspect backend logs for errors, and make sure your authorizationUrl and tokenUrl are set correctly. If nothing happens, add error logging to your sign-in handler and verify that the backend callback endpoint is reachable. If the flow still doesn’t work, try to isolate whether the issue is with the frontend (no redirect) or backend (no response from Autodesk or error in callback handling). Let me know if you see any errors or if the redirect isn’t happening—happy to help dig deeper! <!-- 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/4ac2b7c4-ed38-4efd-8630-1f7163d7f947?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/4ac2b7c4-ed38-4efd-8630-1f7163d7f947?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/4ac2b7c4-ed38-4efd-8630-1f7163d7f947?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/4ac2b7c4-ed38-4efd-8630-1f7163d7f947?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/4ac2b7c4-ed38-4efd-8630-1f7163d7f947?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/4ac2b7c4-ed38-4efd-8630-1f7163d7f947?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/4ac2b7c4-ed38-4efd-8630-1f7163d7f947?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/5773)
Author
Owner

@RobinWitzschke commented on GitHub (Nov 5, 2025):

const handleGenericSocialSignIn = async () => {
try {
const { data, error } = await authClient.signIn.oauth2({
providerId: "autodesk",
callbackURL: "http://localhost:3000/api/auth/oauth2/callback/autodesk",
scopes: ["data:read"],
});
console.log(data);
console.log(error);
} catch (error) {}

so im not catching any error inside the frontend part....

on th ebackend logs i just see GET /en/sign-in? 200 in 79ms (compile: 17ms, proxy.ts: 11ms, render: 51ms) being called how do I log the internal better-auth workflow? im feeling stuck

@dosu

@RobinWitzschke commented on GitHub (Nov 5, 2025): const handleGenericSocialSignIn = async () => { try { const { data, error } = await authClient.signIn.oauth2({ providerId: "autodesk", callbackURL: "http://localhost:3000/api/auth/oauth2/callback/autodesk", scopes: ["data:read"], }); console.log(data); console.log(error); } catch (error) {} so im not catching any error inside the frontend part.... on th ebackend logs i just see GET /en/sign-in? 200 in 79ms (compile: 17ms, proxy.ts: 11ms, render: 51ms) being called how do I log the internal better-auth workflow? im feeling stuck @dosu
Author
Owner

@RobinWitzschke commented on GitHub (Nov 5, 2025):

help @dosu @better-auth-agent

@RobinWitzschke commented on GitHub (Nov 5, 2025): help @dosu @better-auth-agent
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 5, 2025):

Hi there, thanks for reaching out!

Your configuration appears fundamentally sound. Here are a few troubleshooting steps you might find helpful:

  1. Verify that your environment variables (AUTODESK_CLIENT_ID and AUTODESK_CLIENT_SECRET) are correctly loaded and accessible at runtime. An incorrect value here could prevent proper OAuth flow [1].

  2. Check that the discoveryUrl you're using (“https://developer.api.autodesk.com/.well-known/openid-configuration”) returns a valid OpenID configuration. Sometimes a minor error in the endpoint or network issue may cause the genericOAuth plugin not to initialize correctly [2].

  3. Ensure that your callbackURL specified in signIn.oauth2 ("/ms-callback") is correctly set up and reachable. If the sign-in flow is not redirecting, it might be due to misconfiguration in the URL routing or a mismatch with what the provider expects [3].

  4. Double-check that your client and server plugins (genericOAuth on the server and genericOAuthClient on the client) are compatible with your Better Auth version. There have been a few updates in how providers are configured, so verifying documentation for your version might offer additional insights [4].

If these steps don’t resolve the issue, could you share any specific error messages from the browser console or network logs? Tag @bekacru or @ping__ if you need further support.

tag @better-auth-agent if you would like an answer from the Agent. Do you have any additional logs or error details that we can help troubleshoot further?

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Nov 5, 2025): Hi there, thanks for reaching out! Your configuration appears fundamentally sound. Here are a few troubleshooting steps you might find helpful: 1. Verify that your environment variables (AUTODESK_CLIENT_ID and AUTODESK_CLIENT_SECRET) are correctly loaded and accessible at runtime. An incorrect value here could prevent proper OAuth flow [[1]](https://www.better-auth.com/docs/authentication/other-social-providers). 2. Check that the discoveryUrl you're using (“https://developer.api.autodesk.com/.well-known/openid-configuration”) returns a valid OpenID configuration. Sometimes a minor error in the endpoint or network issue may cause the genericOAuth plugin not to initialize correctly [[2]](https://www.better-auth.com/docs/reference/contributing). 3. Ensure that your callbackURL specified in signIn.oauth2 ("/ms-callback") is correctly set up and reachable. If the sign-in flow is not redirecting, it might be due to misconfiguration in the URL routing or a mismatch with what the provider expects [[3]](https://github.com/better-auth/better-auth/issues/4125). 4. Double-check that your client and server plugins (genericOAuth on the server and genericOAuthClient on the client) are compatible with your Better Auth version. There have been a few updates in how providers are configured, so verifying documentation for your version might offer additional insights [[4]](https://www.better-auth.com/). If these steps don’t resolve the issue, could you share any specific error messages from the browser console or network logs? Tag @bekacru or @ping__ if you need further support. tag @better-auth-agent if you would like an answer from the Agent. Do you have any additional logs or error details that we can help troubleshoot further? <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

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

It looks like the OAuth flow isn’t being triggered at all—no errors, no redirect, and no backend callback hits. Here’s how to debug and fix this:

  1. Double-check your frontend sign-in handler: add a console.log before and after the call to authClient.signIn.oauth2 to confirm it’s running. If you don’t see both logs, the handler isn’t firing.
  2. In your sign-in call, set callbackURL to a frontend route like /ms-callback (not the backend callback). The backend callback (/api/auth/oauth2/callback/autodesk) should only be registered with Autodesk, not used in the frontend call. Passing the backend callback as callbackURL will break the flow and can cause silent failures or state errors (source).
  3. Open your browser’s network tab and click the sign-in button. You should see a POST to /api/auth/sign-in/oauth2 and then a redirect to Autodesk. If you don’t, the frontend isn’t triggering the flow—check for JS errors or misconfigurations.
  4. If you see the POST but no redirect, check the response for errors or missing data.
  5. On the backend, enable logging in your Better Auth config:
    logger: {
      level: "debug",
      log: (level, message, ...args) => {
        console.log(`[${level}] ${message}`, ...args);
      }
    }
    
    This will show errors during discovery, token exchange, or user info fetch in your server logs (source).
  6. Make sure your genericOAuth config includes explicit authorizationUrl, tokenUrl, and userInfoUrl fields, even if you use discoveryUrl (source).
  7. If you still see nothing, try creating a dedicated page (e.g., /signin/autodesk) that calls authClient.signIn.oauth2 in a useEffect—this can help isolate frontend issues (source).

If you follow these steps and still don’t see any OAuth activity, paste any errors or network responses you find here and I’ll help you dig deeper.

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 (Nov 5, 2025): <!-- Answer --> It looks like the OAuth flow isn’t being triggered at all—no errors, no redirect, and no backend callback hits. Here’s how to debug and fix this: 1. Double-check your frontend sign-in handler: add a console.log before and after the call to `authClient.signIn.oauth2` to confirm it’s running. If you don’t see both logs, the handler isn’t firing. 2. In your sign-in call, set `callbackURL` to a frontend route like `/ms-callback` (not the backend callback). The backend callback (`/api/auth/oauth2/callback/autodesk`) should only be registered with Autodesk, not used in the frontend call. Passing the backend callback as `callbackURL` will break the flow and can cause silent failures or state errors ([source](https://github.com/better-auth/better-auth/issues/3881)). 3. Open your browser’s network tab and click the sign-in button. You should see a POST to `/api/auth/sign-in/oauth2` and then a redirect to Autodesk. If you don’t, the frontend isn’t triggering the flow—check for JS errors or misconfigurations. 4. If you see the POST but no redirect, check the response for errors or missing data. 5. On the backend, enable logging in your Better Auth config: ```ts logger: { level: "debug", log: (level, message, ...args) => { console.log(`[${level}] ${message}`, ...args); } } ``` This will show errors during discovery, token exchange, or user info fetch in your server logs ([source](https://github.com/better-auth/better-auth/blob/7e6106707539ec9a8510c02cc84ac2e9c2d88db0/docs/content/docs/reference/options.mdx#L494-L545)). 6. Make sure your genericOAuth config includes explicit `authorizationUrl`, `tokenUrl`, and `userInfoUrl` fields, even if you use `discoveryUrl` ([source](https://github.com/better-auth/better-auth/issues/3278)). 7. If you still see nothing, try creating a dedicated page (e.g., `/signin/autodesk`) that calls `authClient.signIn.oauth2` in a `useEffect`—this can help isolate frontend issues ([source](https://github.com/better-auth/better-auth/issues/4327)). If you follow these steps and still don’t see any OAuth activity, paste any errors or network responses you find here and I’ll help you dig deeper. <!-- 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/c59ac186-b8b2-424d-b667-6004609cac74?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c59ac186-b8b2-424d-b667-6004609cac74?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c59ac186-b8b2-424d-b667-6004609cac74?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c59ac186-b8b2-424d-b667-6004609cac74?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c59ac186-b8b2-424d-b667-6004609cac74?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c59ac186-b8b2-424d-b667-6004609cac74?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c59ac186-b8b2-424d-b667-6004609cac74?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/5773)
Author
Owner

@RobinWitzschke commented on GitHub (Nov 5, 2025):

@ping__ @Bekacru

Hey Is there any chance to hop into a discord call with any of you guys?

@RobinWitzschke commented on GitHub (Nov 5, 2025): @ping__ @Bekacru Hey Is there any chance to hop into a discord call with any of you guys?
Author
Owner

@RobinWitzschke commented on GitHub (Nov 5, 2025):

my client component actualy missed ()...

@RobinWitzschke commented on GitHub (Nov 5, 2025): my client component actualy missed ()...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2261