kavachOS
Authentication

VK

Sign in with VK using OAuth 2.0.

Setup

Get credentials

Go to 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

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: 'vk',
          clientId: process.env.VK_CLIENT_ID!,
          clientSecret: process.env.VK_CLIENT_SECRET!,
        },
      ],
    }),
  ],
});
VK_CLIENT_ID=...
VK_CLIENT_SECRET=...

Scopes

Default scopes: email

ScopeWhat it unlocks
emailEmail address
profileName and photo
friendsFriends list

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

Endpoints

MethodPathDescription
GET/auth/oauth/authorize/vkRedirect to VK
GET/auth/oauth/callback/vkHandle callback

On this page