Plugins

Facebook

Official plugin — Facebook Login via Graph API with conservative email handling.

Facebook Login is OAuth2 against the Graph API, and its trust story is the simplest one in oauth(): the platform offers no verification signal to apps, so emails from Facebook are treated as unverified — always.

The one rule

Treat every Facebook-provided address as unverified. The flow provisions new accounts with them but refuses to let them claim accounts that already exist.

Quick start

Create an app

Meta for Developers → Create AppAuthentication. Under Facebook Login → Settings, add https://app.example.com/auth/oauth/callback/facebook as a Valid OAuth Redirect URI.

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: {
      facebook: { enabled: true },
    },
  }),
);

Set the client secret

# .env.local
OAUTH_FACEBOOK_CLIENT_SECRET=...

How identity works

AspectBehavior
Authorizewww.facebook.com/v21.0/dialog/oauth
Token exchangegraph.facebook.com/v21.0/oauth/access_token
ProfileGET /me?fields=id,name,email (the id is the subject)
Emailpresent when the user has one; phone-only accounts have none
Email trustalways unverified — no trustworthy provider signal exists

Consequence: an attacker completing Facebook login with your email gets email_in_use, not your session. This exact scenario is the takeover class the trust matrix closes.

Default scopes: email, public_profile.

Options

OptionTypeDefaultMeaning
enabledbooleanfalseTurn the provider on
clientIdstringVault/env*\*OAUTH_FACEBOOK_CLIENT_ID (App ID)
redirectUristring{baseUrl}…/facebookExact registered URI
scopesstring[]driver defaultsExtra scopes
storeProviderTokensbooleanfalseKeep tokens in Vault

Surfaces

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

Troubleshooting

Learn more

  • OAuth — shared flows and security model
  • X — also never-verified emails
  • Vault — where secrets live

Next

On this page