VK ID Authentication for Website

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1221
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1163
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    855
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1056
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    828
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    825

VK ID Authentication Implementation for Websites

VK ID is VKontakte's unified authorization system, replacing VK Connect. Relevant for Russian-speaking audiences—VK remains the largest social network in Russia and CIS. Supports OAuth2 and new VK ID SDK with improved UX.

Creating Application

  1. vk.com/dev → My appsCreate application
  2. Type: Website
  3. Specify site address and base domain
  4. Save Application ID and Secure key
  5. In settings → Authorization add allowed redirect URIs

Laravel Socialite

composer require laravel/socialite socialiteproviders/vkontakte
// config/services.php
'vkontakte' => [
    'client_id'     => env('VK_CLIENT_ID'),
    'client_secret' => env('VK_CLIENT_SECRET'),
    'redirect'      => env('VK_REDIRECT_URI'),
],

class VkAuthController extends Controller
{
    public function redirect(): RedirectResponse
    {
        return Socialite::driver('vkontakte')->scopes(['email'])->redirect();
    }

    public function callback(): RedirectResponse
    {
        try {
            $vkUser = Socialite::driver('vkontakte')->user();
        } catch (\Exception $e) {
            return redirect('/login')->withErrors(['vk' => 'VK authorization error']);
        }

        $user = User::updateOrCreate(
            ['vk_id' => $vkUser->getId()],
            [
                'name'   => $vkUser->getName(),
                'email'  => $vkUser->getEmail() ?: null,
                'avatar' => $vkUser->getAvatar(),
            ]
        );

        if ($vkUser->getEmail() && !$user->email_verified_at) {
            $user->update(['email_verified_at' => now()]);
        }

        Auth::login($user, remember: true);
        return redirect()->intended('/dashboard');
    }
}

VK OAuth Features

Email available only with explicit scope. Even with scope email, VK passes it not via standard OAuth but in callback parameters. Socialite provider handles this automatically.

Email may not arrive—if user hasn't confirmed email in VK or didn't grant permission.

Avatar: URL returns directly, stays current. No need to cache.

VK ID SDK (New Method)

VKontakte released official VK ID SDK for JavaScript with One Tap support:

<script src="https://unpkg.com/@vkid/sdk@latest/dist-cdn/index.js"></script>
<div id="vkid-container"></div>

<script>
  const { VKID, OneTap, Auth } = window['@vkid/sdk'];
  VKID.Config.init({
    app: parseInt('{{ config("services.vkontakte.client_id") }}'),
    redirectUrl: '{{ config("services.vkontakte.redirect") }}',
    responseMode: VKID.ConfigResponseMode.Callback,
  });

  const oneTap = new OneTap();
  oneTap.render({ container: document.getElementById('vkid-container') })
    .on(Auth.AuthEventType.LOGIN_SUCCESS, (payload) => {
      fetch('/auth/vk/token', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': csrfToken },
        body: JSON.stringify({ silent_token: payload.token, uuid: payload.uuid }),
      });
    });
</script>
// Exchange silent_token for access_token via VK API
public function handleToken(Request $request): JsonResponse
{
    $response = Http::get('https://api.vk.com/method/auth.exchangeSilentAuthToken', [
        'v'            => '5.199',
        'token'        => $request->silent_token,
        'access_token' => config('services.vkontakte.service_token'),
        'uuid'         => $request->uuid,
    ]);

    $data = $response->json('response');
    // $data contains access_token, user_id, email
}

Timeline

OAuth2 flow via Socialite—1–1.5 days. With VK ID SDK and missing email handling—2–3 days.