kavachOS
Authentication

Polar

Sign in with Polar using OAuth 2.0.

Setup

Get credentials

Go to polar.sh and navigate to Settings > OAuth Apps. Create an app and set your redirect URI:

https://your-app.com/api/kavach/auth/oauth/callback/polar

Configure

lib/kavach.ts
import { createKavach } from 'kavachos';
import { oauth } from 'kavachos/auth';

const kavach = await createKavach({
  database: { provider: 'sqlite', url: 'kavach.db' },
  plugins: [
    oauth({
      providers: [
        {
          id: 'polar',
          clientId: process.env.POLAR_CLIENT_ID!,
          clientSecret: process.env.POLAR_CLIENT_SECRET!,
        },
      ],
    }),
  ],
});
POLAR_CLIENT_ID=...
POLAR_CLIENT_SECRET=...

Scopes

Default scopes: openid, profile, email

ScopeWhat it unlocks
openidOIDC identity token
profileUsername and avatar
emailEmail address
organizations:readRead organization memberships

Polar is an open source monetization platform for developers. The OAuth integration is useful for gating content based on subscriptions or purchases.

Endpoints

MethodPathDescription
GET/auth/oauth/authorize/polarRedirect to Polar
GET/auth/oauth/callback/polarHandle callback

On this page