Skip to main content

GitHub OAuth Authentication

Info

The complete source of the following example plugin can be found here: example-plugins/github-auth-plugin

GitHub OAuth authentication allows customers to sign in using their GitHub accounts, eliminating the need for password-based registration.

This is particularly valuable for developer-focused stores or B2B marketplaces.

This guide shows you how to add GitHub OAuth support to your Vendure store using a custom AuthenticationStrategy.

Creating the Plugin

First, use the Vendure CLI to create a new plugin for GitHub authentication:

This creates a basic plugin structure with the necessary files.

Creating the Authentication Strategy

Now create the GitHub authentication strategy. This handles the OAuth flow and creates customer accounts using GitHub profile data:

src/plugins/github-auth-plugin/github-auth-strategy.ts

The strategy uses Vendure's ExternalAuthenticationService to handle customer creation.

It generates a unique email address for each GitHub user to avoid conflicts, and stores the GitHub username as the external identifier for future logins.

Registering the Strategy

Now update the generated plugin file to register your authentication strategy:

src/plugins/github-auth-plugin/github-auth-plugin.plugin.ts

Adding to Vendure Config

Add the plugin to your Vendure configuration:

src/vendure-config.ts

Setting up GitHub OAuth App

Before you can test the integration, you need to create a GitHub OAuth App:

  1. Go to GitHub Settings → Developer settings → OAuth Apps
  2. Click "New OAuth App"
  3. Fill in the required fields:
    • Application name: Your app name (e.g., "My Vendure Store")
    • Homepage URL: http://localhost:3001 (your storefront URL)
    • Authorization callback URL: http://localhost:3001/auth/github/callback
  4. Click "Register application"
  5. Copy the Client ID and generate a Client Secret
Note

The localhost URLs shown here are for local development only. In production, replace localhost:3001 with your actual domain (e.g., https://mystore.com).

Add these credentials to your environment:

.env

Frontend Integration

Creating the Sign-in URL

In your storefront, create a function to generate the GitHub authorization URL:

utils/github-auth.ts

Handling the Callback

Create a callback handler to process the GitHub response and authenticate with Vendure:

pages/auth/github/callback.ts

The OAuth flow follows these steps:

  1. User clicks "Sign in with GitHub" → redirected to GitHub
  2. User authorizes your app → GitHub redirects back with code and state
  3. Your callback exchanges the code for user data → creates Vendure session

Using the GraphQL API

Once your plugin is running, the GitHub authentication will be available in your shop API:

Graphql

Customer Data Management

GitHub-authenticated customers are managed like any other Vendure Customer:

  • Email: Generated as {username}-github@vendure.io to avoid conflicts
  • Verification: Automatically verified (GitHub handles email verification)
  • External ID: GitHub username stored for future authentication
  • Profile: Name extracted from GitHub profile when available

This means GitHub users work seamlessly with Vendure's order management, promotions, and customer workflows.

Testing the Integration

To test your GitHub OAuth integration:

  1. Start your Vendure server with the plugin configured
  2. Navigate to your storefront and click the GitHub sign-in link
  3. Authorize your GitHub app when prompted
  4. Verify that a new customer is created in the Vendure Dashboard
  5. Check that subsequent logins find the existing customer account
Was this chapter helpful?
Report Issue
Edited Feb 10, 2026·Edit this page