From 589df44a9f5dde512a2af7f7fa83021716c7616e Mon Sep 17 00:00:00 2001 From: Tobias Heinze Date: Tue, 7 Oct 2025 16:36:10 +0200 Subject: [PATCH] fix(gitlab): fix the token endpoint (#5147) --- docs/content/docs/authentication/gitlab.mdx | 26 +++++++++++++++++++ .../src/social-providers/gitlab.ts | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/content/docs/authentication/gitlab.mdx b/docs/content/docs/authentication/gitlab.mdx index f459d9d3..9ed5c0b5 100644 --- a/docs/content/docs/authentication/gitlab.mdx +++ b/docs/content/docs/authentication/gitlab.mdx @@ -28,6 +28,32 @@ description: GitLab provider setup and usage. }, }) ``` + + #### Configuration Options + + - `clientId`: Your GitLab application's Client ID + - `clientSecret`: Your GitLab application's Client Secret + - `issuer`: (Optional) The URL of your GitLab instance. Use this for self-hosted GitLab servers. + - Default: `"https://gitlab.com"` (GitLab.com) + - Example: `"https://gitlab.company.com"` + + + The `issuer` option is useful when using a self-hosted GitLab instance. If you're using GitLab.com, you can omit this option as it defaults to `https://gitlab.com`. + + + #### Example with self-hosted GitLab + + ```ts title="auth.ts" + export const auth = betterAuth({ + socialProviders: { + gitlab: { + clientId: process.env.GITLAB_CLIENT_ID as string, + clientSecret: process.env.GITLAB_CLIENT_SECRET as string, + issuer: "https://gitlab.company.com", // Your self-hosted GitLab URL // [!code highlight] + }, + }, + }) + ``` ### Sign In with GitLab diff --git a/packages/better-auth/src/social-providers/gitlab.ts b/packages/better-auth/src/social-providers/gitlab.ts index 54e6a1ac..4de19bde 100644 --- a/packages/better-auth/src/social-providers/gitlab.ts +++ b/packages/better-auth/src/social-providers/gitlab.ts @@ -120,7 +120,7 @@ export const gitlab = (options: GitlabOptions) => { clientKey: options.clientKey, clientSecret: options.clientSecret, }, - tokenEndpoint: "https://gitlab.com/oauth/token", + tokenEndpoint: tokenEndpoint, }); }, async getUserInfo(token) {