Plugins

GitHub

Official plugin — GitHub sign-in with primary-email lookup from the emails API.

GitHub is OAuth2 without discovery or ID tokens, so oauth() builds the identity assertion from two REST calls: /user for the account and /user/emails for the address that actually matters.

The one rule

Request the user:email scope. The public profile email is usually null; the verified primary address only exists on the emails endpoint.

Quick start

Create an OAuth App

GitHub → Settings → Developer settings → OAuth Apps → New OAuth App. Authorization callback URL: https://app.example.com/auth/oauth/callback/github.

Plug it

src/app.ts
import { oke } from "okengine";
import { oauth } from "okengine/plugins";

export const app = oke({
  name: "shop",
  env: "dev",
  gate: { auth: {} },
}).plug(
  oauth({
    baseUrl: "https://app.example.com",
    providers: {
      github: { enabled: true },
    },
  }),
);

Set the client secret

# .env.local
OAUTH_GITHUB_CLIENT_SECRET=...

How identity works

AspectBehavior
Token exchangeform POST to github.com/login/oauth/access_token, JSON accepted
ProfileGET https://api.github.com/user (numeric id is the subject)
EmailGET https://api.github.com/user/emails; picks the entry with primary: true
Email trustverified only when the selected entry has an explicit verified: true

Consequence: a GitHub account whose primary email is unverified never claims that address during sign-up — the flow provisions without verified status instead of risking someone else's inbox.

Default scopes: read:user, user:email. PKCE parameters are sent; GitHub ignores them but the protection stays uniform across providers.

Options

OptionTypeDefaultMeaning
enabledbooleanfalseTurn the provider on
clientIdstringVault/env*\*OAUTH_GITHUB_CLIENT_ID
redirectUristring{baseUrl}…/githubExact registered URI
scopesstring[]driver defaultsExtra scopes
storeProviderTokensbooleanfalseKeep tokens in Vault

Surfaces

FlowPath
StartPOST /auth/oauth/github/start
CallbackGET+POST /auth/oauth/callback/github
LinkPOST /auth/oauth/github/link

Troubleshooting

Learn more

  • OAuth — shared flows and security model
  • Discord — same OAuth2 shape, nullable email
  • Vault — where secrets live

Next

On this page