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/polarConfigure
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
| Scope | What it unlocks |
|---|---|
openid | OIDC identity token |
profile | Username and avatar |
email | Email address |
organizations:read | Read 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
| Method | Path | Description |
|---|---|---|
| GET | /auth/oauth/authorize/polar | Redirect to Polar |
| GET | /auth/oauth/callback/polar | Handle callback |