Vk auth is invalid for this user

Hi!
I’m trying to sign up and log in users with supported 3rd party authentication module vkontakte as written in docs.

const myAuthData = {
        "vkontakte": {
          "id": VK.params.viewer_id,
          "access_token": VK.params.access_token
        }
}

id and access_token are correct.

I’m trying to use user.linkWith and getting errors:

const user = new Parse.User();
await user.linkWith('vkontakte', { authData: myAuthData }); // This authentication method is unsupported.
// or
await user.linkWith('vkontakte', { authData: myAuthData.vkontakte }); //Vk auth is invalid for this user.

My Parse Server options (all correctly set in AWS Elastic Beanstalk environment properties) :

var api = new ParseServer({
  databaseURI: process.env.DATABASE_URI,
  cloud: process.env.CLOUD_CODE_MAIN,
  appId: process.env.APP_ID,
  masterKey: process.env.MASTER_KEY,
  serverURL: process.env.SERVER_URL,
  auth: {
    vkontakte: {
      appSecret: process.env.VK_APP_SECRET, // is correct
      appIds: process.env.VK_APP_ID // is correct
    },
  }
});

How should I make users sign up and log in work with vkontakte authentication module?

It looks that you are passing fixed id and access_token for all users, but you first need your customer to visit a url like this https://oauth.vk.com/authorize?client_id=YOUR_CLIENT_ID&scope=YOUR_SCOPE&redirect_uri=https://localhost&response_type=token, retrieve the user access token and then pass it to parse.

1 Like

Thank you.
I tried and got an error: {"error":"invalid_request","error_description":"OAuth authorization cannot be used from native VK applications"}
It looks like vkontakte authentication module is not suitable for iframe vk apps.