Email from Vkontakte social connection

How to get the email on an user accessing my website using Vkontakte social connection?
I found this and this but still I can get a solution.
Thank you!

Hi @giovannilaperna

It looks like the second post you linked shows how to set up a custom social connection which will allow you to request the email.

Were you able to try this method?

Hi,

I tried with the following but didn’t work:

context.accessToken[namespace + 'email'] = context.email;

I have the following scopes:

openid profile email offline_access

context.email does not exist accordingly to your documentation.

Any suggest?

This is crucial for me since 1/3 of my users will be using Vkontakte to login.

I’m now trying to set up a custom social connection but for some reason it fails.
I contacted vKontakte support for some help because I always get:

error=invalid_request&error_description=Invalid%20user%20id

I don’t know what invalid user id means.

This is solved.

In case someone needs it, the settings and code for Vkontakte custom social connection to get the user email are:

Authorization URL: https://oauth.vk.com/authorize
Token URL : https://oauth.vk.com/access_token
Scope: email
Fetch User Profile Script:

function fetchUserProfile(accessToken, context, callback){
      const profile = {
        id: context.user_id,
        email: context.email
      };
callback (null, profile);
}
1 Like

Thanks for posting your solution!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.