Skip to content

VK ID login for games

A VK app with the SDK of VK ID enabled, and the redirect URI the game comes back to registered in it. The authorization code is exchanged for the identity on the platform, so the app secret never reaches the game.

Choose an environment in the header, open Project settings → Authentication and add a VK ID connection.

FieldMeaning
Client idsThe id of your VK app. One id.
SecretThe secret issued for your VK app.
Redirect uriThe redirect URI you registered for the app; it must be the same one the game used to receive the code.

VK ID returns the authorization code and a device id to the game; send both.

import { Session } from '@rudder/sdk';
const session = await Session.signIn(key, {
provider: 'vk',
payload: { code, deviceId, codeVerifier },
});

codeVerifier is the PKCE verifier the game made for this authorization; leave it out when the game did not use PKCE.

using RudderSdk;
var session = await Session.SignInAsync(key, new ProviderSignIn
{
Provider = "vk",
Payload = new Dictionary<string, object?>
{
["code"] = code,
["deviceId"] = deviceId,
["codeVerifier"] = codeVerifier,
},
});

The platform exchanges the code for the identity of the player with your app, so the exchange never happens in the game. The player is the VK user id.

  • A code that is spent, expired, of another app or of another redirect URI answers 401 unauthorized.
  • VK not answering answers 503 try_again.

The rest are in Errors.