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

# VK

> Authenticate users with VK via the `oauth` plugin. Covers dev.vk.com app setup, redirect URI config, and scopes including `email`, `profile`, and `friends`.

## Setup

<Steps>
  <Step>
    ### Get credentials

    Go to [dev.vk.com](https://dev.vk.com) and create an application. Set the platform to **Website** and add your redirect URI:

    ```
    https://your-app.com/api/kavach/auth/oauth/callback/vk
    ```
  </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: 'vk',
              clientId: process.env.VK_CLIENT_ID!,
              clientSecret: process.env.VK_CLIENT_SECRET!,
            },
          ],
        }),
      ],
    });
    ```

    ```bash theme={"system"}
    VK_CLIENT_ID=...
    VK_CLIENT_SECRET=...
    ```
  </Step>
</Steps>

## Scopes

Default scopes: `email`

| Scope     | What it unlocks |
| --------- | --------------- |
| `email`   | Email address   |
| `profile` | Name and photo  |
| `friends` | Friends list    |

<Info>
  VK returns email as part of the access token response rather than a separate userinfo endpoint. KavachOS handles this automatically.
</Info>

## Endpoints

| Method | Path                       | Description     |
| ------ | -------------------------- | --------------- |
| GET    | `/auth/oauth/authorize/vk` | Redirect to VK  |
| GET    | `/auth/oauth/callback/vk`  | Handle callback |
