medusajs/medusa · critical · Error

Github clientId is required

Error message

Github clientId is required

What it means

The Github auth provider's static `validateOptions` runs at module load/registration time and requires a `clientId`. Without it the provider cannot initiate the OAuth flow, so Medusa throws during startup.

Source

Thrown at packages/modules/providers/auth-github/src/services/github.ts:29

  MedusaError,
} from "@medusajs/framework/utils"

type InjectedDependencies = {
  logger: Logger
}

interface LocalServiceConfig extends GithubAuthProviderOptions {}

export class GithubAuthService extends AbstractAuthModuleProvider {
  static identifier = "github"
  static DISPLAY_NAME = "Github Authentication"

  protected config_: LocalServiceConfig
  protected logger_: Logger

  static validateOptions(options: GithubAuthProviderOptions) {
    if (!options.clientId) {
      throw new Error("Github clientId is required")
    }

    if (!options.clientSecret) {
      throw new Error("Github clientSecret is required")
    }

    if (!options.callbackUrl) {
      throw new Error("Github callbackUrl is required")
    }
  }

  constructor(
    { logger }: InjectedDependencies,
    options: GithubAuthProviderOptions
  ) {
    // @ts-ignore
    super(...arguments)
    this.config_ = options

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Create a Github OAuth app and set clientId in the provider options
  2. Ensure the env var is loaded: `clientId: process.env.GITHUB_CLIENT_ID` and that .env defines it
  3. Redeploy with updated environment secrets

Example fix

// before
{ resolve: '@medusajs/auth-github', id: 'github', options: {} }
// after
{ resolve: '@medusajs/auth-github', id: 'github', options: { clientId: process.env.GITHUB_CLIENT_ID, clientSecret: process.env.GITHUB_CLIENT_SECRET, callbackUrl: `${process.env.MEDUSA_BACKEND_URL}/auth/github/callback` } }
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.GITHUB_CLIENT_ID) {
  throw new Error('GITHUB_CLIENT_ID is required for the github auth provider')
}

Prevention

When it happens

Trigger: Configuring the auth-github provider in medusa-config without `clientId` (or with an unset GITHUB_CLIENT_ID env var).

Common situations: Missing OAuth app credentials in the environment, creating a Github OAuth app but forgetting to copy the client id, or env var name mismatch between .env and config.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/78911b97b1918bf7. Report an issue: GitHub.