PHPackages                             movemoveapp/vkid - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. movemoveapp/vkid

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

movemoveapp/vkid
================

VK ID OAuth 2.1 (id.vk.ru) Socialite provider with PKCE (cache-based, stateless-friendly).

1.0.4(7mo ago)24001MITPHPPHP ^8.0

Since Oct 15Pushed 7mo agoCompare

[ Source](https://github.com/movemoveapp/vkid)[ Packagist](https://packagist.org/packages/movemoveapp/vkid)[ RSS](/packages/movemoveapp-vkid/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

[![](https://avatars.githubusercontent.com/u/121749444?s=400&u=682a6bac6ba993a2a90ec220cfa205540d9d684b&v=4)](https://movemove.com.ru/) VK ID (OAuth 2.1 + PKCE)
================================================================================================================================================================

[](#--vk-id-oauth-21--pkce)

[![Latest Stable Version](https://camo.githubusercontent.com/bf4c818327932dadc6a8d4a2e3c539f6d0080ba73b9ea3f41ff1b1b7f0ff36a0/687474703a2f2f706f7365722e707567782e6f72672f6d6f76656d6f76656170702f766b69642f76)](https://packagist.org/packages/movemoveapp/vkid)[![Total Downloads](https://camo.githubusercontent.com/3a78dc44c0444e6717bb7241574980b7bf08b6fb5e8561590c5288d7ff8a0d3f/687474703a2f2f706f7365722e707567782e6f72672f6d6f76656d6f76656170702f766b69642f646f776e6c6f616473)](https://packagist.org/packages/movemoveapp/vkid)[![Latest Unstable Version](https://camo.githubusercontent.com/56eb6ce72ee011b049dda7afb2e1f8c017c18e934d3caa204e2e43cd6129c174/687474703a2f2f706f7365722e707567782e6f72672f6d6f76656d6f76656170702f766b69642f762f756e737461626c65)](https://packagist.org/packages/movemoveapp/vkid)[![License](https://camo.githubusercontent.com/fab4776dbc5a02c6ceab2eb0902531423cb7a946c4a6657d6584e5f0cdf8998b/687474703a2f2f706f7365722e707567782e6f72672f6d6f76656d6f76656170702f766b69642f6c6963656e7365)](https://packagist.org/packages/movemoveapp/vkid)[![PHP Version Require](https://camo.githubusercontent.com/75030430cf8be19524d06b0b5edd81388c59cbcbaef62c24f9c2a418fe78cf6d/687474703a2f2f706f7365722e707567782e6f72672f6d6f76656d6f76656170702f766b69642f726571756972652f706870)](https://packagist.org/packages/movemoveapp/vkid)

[На Русском](README.ru.md)

```
composer require movemoveapp/vkid
```

Register an application
-----------------------

[](#register-an-application)

Create a new VK ID application at [id.vk.ru](https://id.vk.com/about/business/?utm_source=movemove.com.ru&utm_medium=partner_referral&utm_campaign=vkid_integration&utm_content=laravel+sdk). Make sure you specify the correct redirect URI (must match exactly with the one in your config).

Installation &amp; Basic Usage
------------------------------

[](#installation--basic-usage)

Please see the [Base Installation Guide](https://socialiteproviders.com/usage/) first, then follow the VK ID-specific instructions below.

### Add configuration to `config/services.php`

[](#add-configuration-to-configservicesphp)

```
'vkid' => [
    'client_id'     => env('VKID_CLIENT_ID'),
    'client_secret' => env('VKID_CLIENT_SECRET'),
    'redirect'      => env('VKID_REDIRECT_URI'),

    // --- Extended configuration ---
    'scopes'        => env('VKID_SCOPES', ['email']),                       // default: ['email'], supports ['email','phone']
    'pkce_ttl'      => env('VKID_PKCE_TTL', 10),                            // minutes to store code_verifier
    'cache_store'   => env('VKID_CACHE_STORE', 'redis'),                    // cache store for PKCE verifier
    'cache_prefix'  => env('VKID_CACHE_PREFIX', 'socialite:vkid:pkce:'),
    'api_version'   => env('VKID_API_VERSION', '5.199'),                    // VK API version
],
```

### Add provider event listener

[](#add-provider-event-listener)

#### Laravel 11+

[](#laravel-11)

Since Laravel 11 removed `EventServiceProvider`, use the Event facade in your `AppServiceProvider@boot`:

```
use Illuminate\Support\Facades\Event;
use SocialiteProviders\Manager\SocialiteWasCalled;
use MoveMoveApp\VKID\VKIDExtendSocialite;

public function boot(): void
{
    Event::listen(SocialiteWasCalled::class, [VKIDExtendSocialite::class, 'handle']);
}
```

Laravel 10 or below Add the listener in your `app/Providers/EventServiceProvider.php`. See the \[Base Installation Guide\]() for detailed instructions. ```
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        MoveMoveApp\VKID\VKIDExtendSocialite::class.'@handle',
    ],
];
```

### Usage

[](#usage)

You can now use the driver as usual with Socialite:

```
return Socialite::driver('vkid')->redirect();
```

For extended scopes (e.g. apps with Business Account permission):

```
return Socialite::driver('vkid')
    ->scopes(['email', 'phone'])
    ->redirect();
```

Handling the callback:

```
try {
    $vkUser = Socialite::driver('vkid')->user();

    // Typical fields:
    // $vkUser->getId(), getNickname(), getName(), getEmail(), getAvatar()
    // Optional phone (if scope=phone and app has permission):
    // $vkUser->user['phone'] ?? null

    // Your app logic:
    $localUser = User::firstOrCreate(
        ['email' => $vkUser->getEmail() ?? "vk_{$vkUser->getId()}@example.local"],
        ['name' => $vkUser->getName()]
    );

    Auth::login($localUser);
    return redirect()->intended('/');
} catch (\Laravel\Socialite\Two\InvalidStateException $e) {
    // Thrown when PKCE verifier expired (user waited too long)
    return redirect()->route('login')->with('auth_error', 'Authorization expired. Please try again.');
} catch (\RuntimeException $e) {
    // Thrown when cache store is unavailable/misconfigured
    report($e);
    return redirect()->route('login')->with('auth_error', 'Temporary VK ID authorization error.');
} catch (\Throwable $e) {
    report($e);
    return redirect()->route('login')->with('auth_error', 'Unexpected VK ID login error.');
}
```

### Returned User fields

[](#returned-user-fields)

FieldDescription`id`VK user ID`nickname`screen\_name (if present)`name`First + last name`email`from id\_token (if scope=email)`avatar`URL to 200px profile photo`phone`from id\_token (if scope=phone and granted)### Exception Reference

[](#exception-reference)

ExceptionCauseRecommended handling`Laravel\Socialite\Two\InvalidStateException`- state or PKCE verifier missing or expired- user waited longer than pkce\_ttl minutes before pressing “Allow”Ask user to restart login. Show message like “Authorization expired. Please try again.”`RuntimeException("VKID PKCE cache failure")`Cache store misconfigured or unavailable (e.g., Redis down)Log and retry later. Typically a server-side infra issue.`RuntimeException("VKID PKCE cache failure: unable to persist code_verifier")`Misconfigured cache\_store or permission issue writing PKCE stateEnsure correct cache driver in config/cache.php`Any other exception`Networking or unexpected JSON formatGeneric fallback “VK ID login failed”All exceptions extend base \\Throwable and can be caught globally in your app’s Handler.

### Extended Configuration Options

[](#extended-configuration-options)

KeyTypeDefaultDescription`client\_idstring–VK App ID`client\_secretstring–VK App secret`redirectstring–Full callback URL (must match app settings)`scopesarray\['email'\]Default OAuth scopes`pkce\_ttlint10Time in minutes to store PKCE verifier`cache\_storestring'redis'Cache store for PKCE (see config/cache.php)`cache\_prefixstring'socialite:vkid:pkce:'Prefix for PKCE keys`api\_versionstring'5.199'VK API version for users.get### Example .env

[](#example-env)

```
VKID_CLIENT_ID=1234567
VKID_CLIENT_SECRET=secretkey
VKID_REDIRECT_URI=https://your-app.com/auth/vkid/callback

VKID_SCOPES="['email','phone']"
VKID_PKCE_TTL=10
VKID_CACHE_STORE=redis
VKID_CACHE_PREFIX=socialite:vkid:pkce:
VKID_API_VERSION=5.199
```

### Example User Flow Diagram

[](#example-user-flow-diagram)

```
Client  →  https://id.vk.ru/authorize?response_type=code&state=XYZ...
   ↳ Redirects user back to /auth/vkid/callback?code=...&state=XYZ
Provider  →  Exchanges code for tokens (with code_verifier)
   ↳ Fetches user profile via api.vk.com/method/users.get
App  →  Creates/logs in user, handles avatar/email/phone sync

```

---

### Reference

[](#reference)

- [VK ID Developer Docs (OAuth 2.1)](https://id.vk.com/docs)
- [VK API Reference](https://dev.vk.com/method/users.get)
- [Laravel Socialite Documentation](https://laravel.com/docs/12.x/socialite)
- [SocialiteProviders.com Usage Guide](https://socialiteproviders.com/usage/)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance65

Regular maintenance activity

Popularity21

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

214d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2510798?v=4)[Dmitriy Kovalev](/maintainers/pipisco)[@pipisco](https://github.com/pipisco)

---

Tags

laravelsdkoauthvkpkcemovemove

### Embed Badge

![Health badge](/badges/movemoveapp-vkid/health.svg)

```
[![Health](https://phpackages.com/badges/movemoveapp-vkid/health.svg)](https://phpackages.com/packages/movemoveapp-vkid)
```

###  Alternatives

[socialiteproviders/manager

Easily add new or override built-in providers in Laravel Socialite.

42542.0M544](/packages/socialiteproviders-manager)[socialiteproviders/microsoft

Microsoft OAuth2 Provider for Laravel Socialite

326.1M13](/packages/socialiteproviders-microsoft)[socialiteproviders/instagram

Instagram OAuth2 Provider for Laravel Socialite

421.9M5](/packages/socialiteproviders-instagram)[kovah/laravel-socialite-oidc

OpenID Connect OAuth2 Provider for Laravel Socialite

2073.7k](/packages/kovah-laravel-socialite-oidc)[bocharsky-bw/vkontakte-php-sdk

Vkontakte PHP SDK

3259.2k1](/packages/bocharsky-bw-vkontakte-php-sdk)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
