VK ID login for games
Before you start
Section titled “Before you start”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.
In the Dashboard
Section titled “In the Dashboard”Choose an environment in the header, open Project settings → Authentication and add a VK ID connection.
| Field | Meaning |
|---|---|
Client ids | The id of your VK app. One id. |
Secret | The secret issued for your VK app. |
Redirect uri | The redirect URI you registered for the app; it must be the same one the game used to receive the code. |
In the game
Section titled “In the game”VK ID returns the authorization code and a device id to the game; send both.
TypeScript
Section titled “TypeScript”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.
C# and Unity
Section titled “C# and Unity”using RudderSdk;
var session = await Session.SignInAsync(key, new ProviderSignIn{ Provider = "vk", Payload = new Dictionary<string, object?> { ["code"] = code, ["deviceId"] = deviceId, ["codeVerifier"] = codeVerifier, },});What the platform checks
Section titled “What the platform checks”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.
Errors
Section titled “Errors”- 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.