Skip to content
Migrating from NextAuth.js v4? Read our migration guide.
API reference
vk

providers/vk

Built-in VK integration.

VkProfile

https://dev.vk.com/reference/objects/user

Properties

about?

optional about: string;

activities?

optional activities: string;

bdate?

optional bdate: string;

blacklisted?

optional blacklisted: 0 | 1;

blacklisted_by_me?

optional blacklisted_by_me: 0 | 1;

books?

optional books: string;

can_access_closed

can_access_closed: boolean;

can_post?

optional can_post: 0 | 1;

can_see_all_posts?

optional can_see_all_posts: 0 | 1;

can_see_audio?

optional can_see_audio: 0 | 1;

can_send_friend_request?

optional can_send_friend_request: 0 | 1;

can_write_private_message?

optional can_write_private_message: 0 | 1;

career?

optional career: {
  city_id: number;
  city_name: string;
  company: string;
  country_id: number;
  from: number;
  group_id: number;
  position: string;
  until: number;
};
city_id?
optional city_id: number;
city_name?
optional city_name: string;
company?
optional company: string;
country_id?
optional country_id: number;
from?
optional from: number;
group_id?
optional group_id: number;
position?
optional position: string;
until?
optional until: number;

city?

optional city: {
  id: number;
  title: string;
};
id
id: number;
title
title: string;

common_count?

optional common_count: number;

connections?

optional connections: {
  facebook: string;
  instagram: string;
  livejournal: string;
  skype: string;
  twitter: string;
};
facebook?
optional facebook: string;
instagram?
optional instagram: string;
livejournal?
optional livejournal: string;
skype?
optional skype: string;
twitter?
optional twitter: string;

contacts?

optional contacts: {
  home_phone: string;
  mobile_phone: string;
};
home_phone?
optional home_phone: string;
mobile_phone?
optional mobile_phone: string;

counters?

optional counters: {
  albums: number;
  audios: number;
  followers: number;
  friends: number;
  groups: number;
  mutual_friends: number;
  notes: number;
  online_friends: number;
  pages: number;
  photos: number;
  user_videos: number;
  videos: number;
};
albums?
optional albums: number;
audios?
optional audios: number;
followers?
optional followers: number;
friends?
optional friends: number;
groups?
optional groups: number;
mutual_friends?
optional mutual_friends: number;
notes?
optional notes: number;
online_friends?
optional online_friends: number;
pages?
optional pages: number;
photos?
optional photos: number;
user_videos?
optional user_videos: number;
videos?
optional videos: number;

country?

optional country: {
  id: number;
  title: string;
};
id
id: number;
title
title: string;

crop_photo?

optional crop_photo: {
  crop: {
     x: number;
     x2: number;
     y: number;
     y2: number;
  };
  photo: {
     access_key: string;
     album_id: number;
     can_comment: 0 | 1;
     date: number;
     has_tags: boolean;
     height: number;
     id: number;
     images: {
        height: number;
        type:   | "p"
           | "q"
           | "s"
           | "m"
           | "x"
           | "l"
           | "o"
           | "r"
           | "y"
           | "z"
           | "w";
        url: string;
        width: number;
     }[];
     lat: number;
     long: number;
     owner_id: number;
     photo_256: string;
     place: string;
     post_id: number;
     sizes: {
        height: number;
        src: string;
        type:   | "max"
           | "k"
           | "a"
           | "b"
           | "i"
           | "p"
           | "q"
           | "s"
           | "g"
           | "m"
           | "x"
           | "l"
           | "o"
           | "r"
           | "y"
           | "z"
           | "w"
           | "c"
           | "e"
           | "d"
           | "j"
           | "temp"
           | "h"
           | "n"
           | "f";
        url: string;
        width: number;
     }[];
     text: string;
     user_id: number;
     width: number;
  };
  rect: {
     x: number;
     x2: number;
     y: number;
     y2: number;
  };
};
crop
crop: {
  x: number;
  x2: number;
  y: number;
  y2: number;
};
crop.x
x: number;
crop.x2
x2: number;
crop.y
y: number;
crop.y2
y2: number;
photo
photo: {
  access_key: string;
  album_id: number;
  can_comment: 0 | 1;
  date: number;
  has_tags: boolean;
  height: number;
  id: number;
  images: {
     height: number;
     type:   | "p"
        | "q"
        | "s"
        | "m"
        | "x"
        | "l"
        | "o"
        | "r"
        | "y"
        | "z"
        | "w";
     url: string;
     width: number;
  }[];
  lat: number;
  long: number;
  owner_id: number;
  photo_256: string;
  place: string;
  post_id: number;
  sizes: {
     height: number;
     src: string;
     type:   | "max"
        | "k"
        | "a"
        | "b"
        | "i"
        | "p"
        | "q"
        | "s"
        | "g"
        | "m"
        | "x"
        | "l"
        | "o"
        | "r"
        | "y"
        | "z"
        | "w"
        | "c"
        | "e"
        | "d"
        | "j"
        | "temp"
        | "h"
        | "n"
        | "f";
     url: string;
     width: number;
  }[];
  text: string;
  user_id: number;
  width: number;
};
photo.access_key?
optional access_key: string;
photo.album_id
album_id: number;
photo.can_comment?
optional can_comment: 0 | 1;
photo.date
date: number;
photo.has_tags
has_tags: boolean;
photo.height?
optional height: number;
photo.id
id: number;
photo.images?
optional images: {
  height: number;
  type:   | "p"
     | "q"
     | "s"
     | "m"
     | "x"
     | "l"
     | "o"
     | "r"
     | "y"
     | "z"
     | "w";
  url: string;
  width: number;
  }[];
photo.lat?
optional lat: number;
photo.long?
optional long: number;
photo.owner_id
owner_id: number;
photo.photo_256?
optional photo_256: string;
photo.place?
optional place: string;
photo.post_id?
optional post_id: number;
photo.sizes?
optional sizes: {
  height: number;
  src: string;
  type:   | "max"
     | "k"
     | "a"
     | "b"
     | "i"
     | "p"
     | "q"
     | "s"
     | "g"
     | "m"
     | "x"
     | "l"
     | "o"
     | "r"
     | "y"
     | "z"
     | "w"
     | "c"
     | "e"
     | "d"
     | "j"
     | "temp"
     | "h"
     | "n"
     | "f";
  url: string;
  width: number;
  }[];
photo.text?
optional text: string;
photo.user_id?
optional user_id: number;
photo.width?
optional width: number;
rect
rect: {
  x: number;
  x2: number;
  y: number;
  y2: number;
};
rect.x
x: number;
rect.x2
x2: number;
rect.y
y: number;
rect.y2
y2: number;

deactivated?

optional deactivated: string;

domain?

optional domain: string;

education?

optional education: {
  faculty: number;
  faculty_name: string;
  graduation: number;
  university: number;
  university_name: string;
};
faculty?
optional faculty: number;
faculty_name?
optional faculty_name: string;
graduation?
optional graduation: number;
university?
optional university: number;
university_name?
optional university_name: string;

email?

optional email: string;

exports?

optional exports: {
  facebook: number;
  instagram: number;
  livejournal: number;
  twitter: number;
};
facebook?
optional facebook: number;
instagram?
optional instagram: number;
livejournal?
optional livejournal: number;
twitter?
optional twitter: number;

first_name

first_name: string;

first_name_abl?

optional first_name_abl: string;

first_name_acc?

optional first_name_acc: string;

first_name_dat?

optional first_name_dat: string;

first_name_gen?

optional first_name_gen: string;

first_name_ins?

optional first_name_ins: string;

first_name_nom?

optional first_name_nom: string;

followers_count?

optional followers_count: number;

friend_status?

optional friend_status: 0 | 2 | 1 | 3;

games?

optional games: string;

has_mobile?

optional has_mobile: 0 | 1;

has_photo?

optional has_photo: 0 | 1;

home_town?

optional home_town: string;

id

id: number;

interests?

optional interests: string;

is_closed

is_closed: boolean;

is_favorite?

optional is_favorite: 0 | 1;

is_friend?

optional is_friend: 0 | 1;

is_hidden_from_feed?

optional is_hidden_from_feed: 0 | 1;

is_no_index?

optional is_no_index: 0 | 1;

last_name

last_name: string;

last_name_abl?

optional last_name_abl: string;

last_name_acc?

optional last_name_acc: string;

last_name_dat?

optional last_name_dat: string;

last_name_gen?

optional last_name_gen: string;

last_name_ins?

optional last_name_ins: string;

last_name_nom?

optional last_name_nom: string;

last_seen?

optional last_seen: {
  platform:   | 2
     | 1
     | 5
     | 3
     | 4
     | 6
     | 7;
  time: number;
};
platform?
optional platform: 
  | 2
  | 1
  | 5
  | 3
  | 4
  | 6
  | 7;
time?
optional time: number;

maiden_name?

optional maiden_name: string;

military?

optional military: {
  country_id: number;
  from: number;
  unit: string;
  unit_id: number;
  until: number;
};
country_id
country_id: number;
from?
optional from: number;
unit
unit: string;
unit_id
unit_id: number;
until?
optional until: number;

movies?

optional movies: string;

music?

optional music: string;

nickname?

optional nickname: string;

occupation?

optional occupation: {
  id: number;
  name: string;
  type: "work" | "school" | "university";
};
id?
optional id: number;
name?
optional name: string;
type?
optional type: "work" | "school" | "university";

online?

optional online: 0 | 1;

online_app?

optional online_app: number;

online_mobile?

optional online_mobile: 0 | 1;

personal?

optional personal: {
  alcohol:   | 2
     | 1
     | 5
     | 3
     | 4;
  inspired_by: string;
  langs: string[];
  life_main:   | 2
     | 1
     | 5
     | 3
     | 4
     | 6
     | 7
     | 8;
  people_main:   | 2
     | 1
     | 5
     | 3
     | 4
     | 6;
  political:   | 2
     | 1
     | 5
     | 3
     | 4
     | 6
     | 7
     | 8
     | 9;
  religion: string;
  smoking:   | 2
     | 1
     | 5
     | 3
     | 4;
};
alcohol?
optional alcohol: 
  | 2
  | 1
  | 5
  | 3
  | 4;
inspired_by?
optional inspired_by: string;
langs?
optional langs: string[];
life_main?
optional life_main: 
  | 2
  | 1
  | 5
  | 3
  | 4
  | 6
  | 7
  | 8;
people_main?
optional people_main: 
  | 2
  | 1
  | 5
  | 3
  | 4
  | 6;
political?
optional political: 
  | 2
  | 1
  | 5
  | 3
  | 4
  | 6
  | 7
  | 8
  | 9;
religion?
optional religion: string;
smoking?
optional smoking: 
  | 2
  | 1
  | 5
  | 3
  | 4;

photo_100

photo_100: string;

photo_200?

optional photo_200: string;

photo_200_orig?

optional photo_200_orig: string;

photo_400?

optional photo_400: string;

photo_400_orig?

optional photo_400_orig: string;

photo_50?

optional photo_50: string;

photo_id?

optional photo_id: string;

photo_max?

optional photo_max: string;

photo_max_orig?

optional photo_max_orig: string;

quotes?

optional quotes: string;

relation?

optional relation: 
  | 0
  | 2
  | 1
  | 5
  | 3
  | 4
  | 6
  | 7
  | 8;

relation_partner?

optional relation_partner: {
  can_access_closed: boolean;
  deactivated: string;
  first_name: string;
  hidden: number;
  id: number;
  is_closed: boolean;
  last_name: string;
};
can_access_closed?
optional can_access_closed: boolean;
deactivated?
optional deactivated: string;
first_name
first_name: string;
hidden?
optional hidden: number;
id
id: number;
is_closed?
optional is_closed: boolean;
last_name
last_name: string;

relatives?

optional relatives: {
  id: number;
  name: string;
  type:   | "parent"
     | "child"
     | "grandparent"
     | "grandchild"
     | "sibling";
  }[];

schools?

optional schools: {
  city: number;
  class: string;
  country: number;
  id: string;
  name: string;
  speciality: string;
  type: number;
  type_str: string;
  year_from: number;
  year_graduated: number;
  year_to: number;
  }[];

screen_name?

optional screen_name: string;

sex?

optional sex: 0 | 2 | 1;

site?

optional site: string;

status?

optional status: string;

status_audio?

optional status_audio: {
  access_key: string;
  album_id: number;
  artist: string;
  date: number;
  duration: number;
  genre_id: number;
  id: number;
  owner_id: number;
  performer: string;
  title: string;
  url: string;
};
access_key?
optional access_key: string;
album_id?
optional album_id: number;
artist
artist: string;
date?
optional date: number;
duration
duration: number;
genre_id?
optional genre_id: number;
id
id: number;
owner_id
owner_id: number;
performer?
optional performer: string;
title
title: string;
url?
optional url: string;

timezone?

optional timezone: number;

trending?

optional trending: 0 | 1;

tv?

optional tv: string;

universities?

optional universities: {
  chair: number;
  chair_name: string;
  city: number;
  country: number;
  education_form: string;
  education_status: string;
  faculty: number;
  faculty_name: string;
  graduation: number;
  id: number;
  name: string;
  university_group_id: number;
  }[];

verified?

optional verified: 0 | 1;

wall_default?

optional wall_default: "all" | "owner";

default()

default<P>(options): OAuthConfig<P>

Add VK login to your page.

Setup

Callback URL

https://example.com/api/auth/callback/vk

Configuration

import Auth from "@auth/core"
import VK from "@auth/core/providers/vk"
 
const request = new Request(origin)
const response = await Auth(request, {
  providers: [VK({ clientId: VK_CLIENT_ID, clientSecret: VK_CLIENT_SECRET })],
})

Resources

Notes

By default, Auth.js assumes that the VK provider is based on the OAuth 2 specification.

đź’ˇ

The VK provider comes with a default configuration. To override the defaults for your use case, check out customizing a built-in OAuth provider.

By default the provider uses 5.126 version of the API. See https://vk.com/dev/versions for more info. If you want to use a different version, you can pass it to provider’s options object:

pages/api/auth/[...nextauth].js
const apiVersion = "5.126"
providers: [
  VkProvider({
    accessTokenUrl: `https://oauth.vk.com/access_token?v=${apiVersion}`,
    requestTokenUrl: `https://oauth.vk.com/access_token?v=${apiVersion}`,
    authorizationUrl:
      `https://oauth.vk.com/authorize?response_type=code&v=${apiVersion}`,
    profileUrl: `https://api.vk.com/method/users.get?fields=photo_100&v=${apiVersion}`,
  })
]

Disclaimer If you think you found a bug in the default configuration, you can open an issue.

Auth.js strictly adheres to the specification and it cannot take responsibility for any deviation from the spec by the provider. You can open an issue, but if the problem is non-compliance with the spec, we might not pursue a resolution. You can ask for more help in Discussions.

Type parameters

Type parameterValue
P extends Record<string, any>VkProfile

Parameters

ParameterType
optionsOAuthUserConfig<P>

Returns

OAuthConfig<P>

Auth.js © Balázs Orbán and Team - 2024