> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kavachos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Polar

> Authenticate users via Polar OAuth 2.0. Register an OAuth app in Polar settings, configure the `polar` provider, and request `organizations:read` for org access.

## Setup

<Steps>
  <Step>
    ### Get credentials

    Go to [polar.sh](https://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
    ```
  </Step>

  <Step>
    ### Configure

    ```ts title="lib/kavach.ts" theme={"system"}
    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!,
            },
          ],
        }),
      ],
    });
    ```

    ```bash theme={"system"}
    POLAR_CLIENT_ID=...
    POLAR_CLIENT_SECRET=...
    ```
  </Step>
</Steps>

## 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 |

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

## Endpoints

| Method | Path                          | Description       |
| ------ | ----------------------------- | ----------------- |
| GET    | `/auth/oauth/authorize/polar` | Redirect to Polar |
| GET    | `/auth/oauth/callback/polar`  | Handle callback   |
