Plugins

X

Official plugin — X (Twitter) sign-in as a PKCE public client with confidential-client secrets left out.

X is the one provider where oauth() behaves as a public client: the token exchange carries the code verifier but no secret. PKCE is the only proof the callback is yours.

The one rule

Enable OAuth 2.0 in the X Developer Portal, set up your exact callback URI, and request users.email access if you need addresses. No OAUTH_X_CLIENT_SECRET exists — none is read.

Quick start

Configure the app

X Developer Portal → Project → User authentication settings → Set up. Choose Web App, enable OAuth 2.0, and add https://app.example.com/auth/oauth/callback/x as a callback 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: {
      x: { enabled: true },
    },
  }),
);

That is the whole setup — no Vault contract for this provider.

How identity works

AspectBehavior
Token exchangePOST https://api.x.com/2/oauth2/token with the code verifier, no secret
ProfileGET /2/users/me?user.fields=id,name,username,confirmed_email
Subjectthe string id inside data
Email trustalways unverifiedconfirmed_email gates API access, it does not attest verification

Consequence: an X email never claims an existing account during sign-up. It can attach to a fresh account or to an existing one you already control via authenticated linking.

Default scopes: users.read, tweet.read.

Options

OptionTypeDefaultMeaning
enabledbooleanfalseTurn the provider on
clientIdstringVault/env*\*OAUTH_X_CLIENT_ID
redirectUristring{baseUrl}…/xExact registered URI
scopesstring[]driver defaultsExtra scopes (offline.access, …)
storeProviderTokensbooleanfalseKeep tokens in Vault

Surfaces

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

Troubleshooting

Learn more

  • OAuth — shared flows and security model
  • Facebook — also never-verified emails
  • Vault — optional token storage

Next

On this page