Platform

Sign Up With VKontakte

10min

Sign In with VK (VKontakte) Tutorial

Introduction

Sign In with VK (VKontakte) enables users to sign in to Apps using their VK accounts.

Prerequisites

To complete this tutorial, you will need:

1 - Create a New Back4App App

First of all, it’s necessary to make sure that you have an existing app created at Back4App. However, if you are a new user, you can check this tutorial to learn how to create one.

2 - Create a new VK App

Create a new VK Application by going to VK Developers and clicking the Create app button

Document image


Fill up the Title and choose the Platform as Standalone app, then click the Connect app button

Document image


Choose a Category for your app and, if applicable, a Type of leaderboard, and Community. Click Save

Document image


Under the Settings tab of your VK Application, you will find your App ID, Secure key, and Service token among other useful info. Fill up your Website address and the Base domain for it. Save it.

Document image


3 - Retrieve your Code

Copy the App ID from your to use as the YOUR_CLIENT_ID and use your Website address as YOUR_REDIRECT_URI, and choose a scope to use in YOUR_SCOPE from the available options.

Then visit the following URL changing the parameters above:

https://oauth.vk.com/authorize?client_id=YOUR_CLIENT_ID&scope=YOUR_SCOPE&redirect_uri=https://localhost&response_type=token

It will ask you to log in to VK:

Document image


Alternatively, you can use the following CURL command to retrieve your token:

Curl


Run it and you should retrieve your access token:

Document image


REMEMBER: the code can be used only once. If you get an error or don’t use your token, you must re-generate your Code to be able to run it again.

4 - Configure your Back4app App

In your Back4app App, go to Server Settings and open the VKontakte Login box

Document image


Fill up your Application Id and VKontakte Application Secret. Save it.

Document image


5 - Start the development

Now that the Sign-in with VK is configured, you can start the development process. The format for AUTHDATA is:

JSON


Here is the method for the iOS SDK:

Swift


And here for the Android SDK

Java