GitHub Auth Module Provider

In this document, you’ll learn about the GitHub Auth Module Provider and how to install and use it in the Auth Module.

The Github Auth Module Provider authenticates users with their GitHub account.

TipLearn about the authentication flow in this guide .

Register the Github Auth Module Provider#

Add the module to the array of providers passed to the Auth Module:

medusa-config.ts
1import { Modules } from "@medusajs/framework/utils"2
3// ...4
5const modules = {6  // ...7  [Modules.AUTH]: {8    resolve: "@medusajs/medusa/auth",9    options: {10      providers: [11        // other providers...12        {13          resolve: "@medusajs/medusa/auth-github",14          id: "github",15          options: {16            clientId: process.env.GITHUB_CLIENT_ID,17            clientSecret: process.env.GITHUB_CLIENT_SECRET,18            callbackUrl: process.env.GITHUB_CALLBACK_URL,19          },20        },21      ],22    },23  },24}

Environment Variables#

Make sure to add the necessary environment variables for the above options in .env:

Code
1GITHUB_CLIENT_ID=<YOUR_GITHUB_CLIENT_ID>2GITHUB_CLIENT_SECRET=<YOUR_GITHUB_CLIENT_SECRET>3GITHUB_CALLBACK_URL=<YOUR_GITHUB_CALLBACK_URL>

Module Options#

ConfigurationDescriptionRequired

clientId

A string indicating the client ID of your GitHub app.

Yes

clientSecret

A string indicating the client secret of your GitHub app.

Yes

callbackUrl

A string indicating the URL to redirect to in your frontend after the user completes their authentication in GitHub.

At this URL, the frontend will receive a code query parameter. It then sends that code query parameter to the Medusa application's /auth/{actor_type}/github/callback route.

Yes


Examples#

Was this page helpful?
Edit this page