Skip to main content

Android

This article guides you through setting up VK as an identity provider, enabling your Android game to access Player Network authentication services.

Prerequisites

1. Set up the VK App on the VK developer website

1. Create a VK app

info

The following information was last updated on February 5, 2024. For the latest information, refer to VK developer website.

caution

VK apps can no longer be created from the VK developer website, follow the below steps to be redirected to the VK ID developer website.
VK ID is not supported by Player Network SDK at the moment. For detailed information and version support plans, reach out to the Player Network represenative.

  1. Log in, or register for an account on the VK developer website.

  2. Go to the Create an app page and enter the below information.

    • Title: Name of the app
    • Platform: Type of app to be created
  3. Click Go to service to be redirected to the VK ID developer website.

    Image: VK Create App

2. Configure the app

Enter App information
  1. Go to the VK developer website.

  2. Enter the app information on the Information page of the corresponding app.

    Image: VK information

  3. Click Save to save the entered information.

Enable OpenAPI

Image: VK app base domain

  1. Enable OpenAPI.
  2. Add the following base domains:
    • dev-common-web.intlgame.com
    • debug-common-web.intlgame.com
    • test-common-web.intlgame.com
    • common-web.intlgame.com
Get Android Fingerprint

To get the Android fingerprint, follow the instructions in Get the SHA1 Value for Android.

Image: VK SHA1

SDK Settings
  1. Go to the Settings page of the app.

  2. In the SDK settings section, enter App Bundle ID for iOSPackage name for Android, and Signing certificate fingerprint for Android.

    Image: VK SDK Setting

Get App ID, Secure key and other information

Go to the Settings page of the app, and get the App ID and other information.

Image: Player Network config

  1. Create an account for Player Network Console.
  2. Create a new project for your game, or join an existing one.
  3. Download the SDK.
  4. Integrate the SDK.
  5. Add VK as an authentication method for your project on Player Network Console.

Step 1: Configure the SDK for VK login

  1. In the AndroidManifest file, make sure the required permissions have been added. VK requires access to the network.

    <uses-permission android:name="android.permission.INTERNET"/>
  2. In the vk_integers.xml file under Assets/Plugins/Android/INTLVK.androidlib/res/values, add the following configurations.

    <integer name="com_vk_sdk_AppId">your_app_id</integer>

    Replace your_app_id with the registered VK App ID.

  3. Open the project's INTLConfig.ini:

    [Android LifeCycle]
    LIFECYCLE = VK
    [VK]
    VK_APP_ID = {INTL_VK_APP_ID}
    • Add VK to LIFECYCLE. For more information, see SDK environment.
    • Replace {INTL_VK_APP_ID} with the registered VK App ID.

Step 2: Add VK login

  1. Add an observer to handle authentication callbacks.

    // Add callbacks
    public void AddAuthObserver()
    {
    INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
    }

    // Remove callbacks
    public void RemoveAuthObserver()
    {
    INTLAPI.RemoveAuthResultObserver(OnAuthResultEvent);
    }

    // Process the INTLAuthResult callback
    public void OnAuthResultEvent(INTLAuthResult ret)
    {
    Debug.Log($"MethodID: {ret.MethodId}");

    string methodTag = "";
    if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_LOGIN)
    {
    methodTag = "Login";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_BIND)
    {
    methodTag = "Bind";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_AUTOLOGIN)
    {
    methodTag = "AutoLogin";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO)
    {
    methodTag = "QueryUserInfo";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT)
    {
    methodTag = "GetAuthResult";
    }
    }
  2. Call the AutoLogin method.

    INTLAPI.AutoLogin();
  3. Call the Login method to ask for user input if auto-login fails.

    INTLAPI.Login(INTLChannel.VK); 
  4. Sync client authentication state with the game's backend and wait for the final authentication result.

Step 3: Test the login function

Search for the keyword "AuthResult" in the Player Network SDK logs to verify if the correct channel name and OpenID are returned. If they are, it indicates a successful configuration and the login function has been added successfully.