GitLab OAuth

GitLab OAuth with PKCE and self-hosted instance support.

Overview

GitLab OAuth supports PKCE (S256) by default. For self-hosted GitLab, pass your base URL via thedomain option (defaults to https://gitlab.com).

Environment

# .env.local
AUTH_SECRET=your-secret-key-min-32-chars-long
GITLAB_CLIENT_ID=your-gitlab-client-id
GITLAB_CLIENT_SECRET=your-gitlab-client-secret
GITLAB_REDIRECT_URI=http://localhost:3000/api/auth/callback/gitlab

Configuration

Basic GitLab OAuth Setup

Hosted on gitlab.com

import { gitlab } from '@warpy-auth-sdk/core';

const provider = gitlab({
  clientId: process.env.GITLAB_CLIENT_ID!,
  clientSecret: process.env.GITLAB_CLIENT_SECRET!,
  redirectUri: process.env.GITLAB_REDIRECT_URI!,
  scope: ['read_user', 'email'],
});

Self-hosted GitLab

Using a custom domain

const provider = gitlab({
  clientId: process.env.GITLAB_CLIENT_ID!,
  clientSecret: process.env.GITLAB_CLIENT_SECRET!,
  redirectUri: process.env.GITLAB_REDIRECT_URI!,
  domain: 'https://gitlab.mycompany.com',
});

Scopes

Use read_user for basic profile and email for the user's email.
GitLab OAuth | @warpy-auth-sdk/core