How to get email address from vk.api?
Asked Answered
C

5

6

Im trying to get email address. After success login i have firstname, lastname, all except email. please help.

VK.Auth.login(function (response) {
            if (response.session) {


            } else {

            }
        }, 4194304);
Chladek answered 27/8, 2014 at 13:41 Comment(1)
email is only for websites (mask +4194304). vk.com/dev/permissionsIce
K
0

There is no way to do that. Vk is specific social network.

Ketchan answered 18/9, 2014 at 10:17 Comment(0)
A
7

When you get Access Token, VK also gives you Email and User ID, but you need specific permission for that - "email".

Afra answered 10/4, 2015 at 10:4 Comment(1)
That's the correct answer! Just have made id that way. I would be glad if I could first read this, then look all over other places in the internet. :)Pneumonia
N
1

vk.com now has that functionality. Try checking out this documentation page: https://vk.com/dev/permissions

Nisen answered 6/1, 2015 at 15:20 Comment(1)
The author above (Evgeniy Shinkarenko) has described the probem from pointed you documentation, He asked why is it not work.Brandiebrandise
B
1

Yes this way does not give the email. But there is the way to get email via OAuth (for sites vk.com/dev/auth_sites), email will be returned in GET parameters along with token.

in Coffescript/Javascript you can use window.open(...)

appId = 'your app id'
redirectUri = 'your redirect uri'
url = 'https://oauth.vk.com/authorize?client_id='+appId+'&display=popup&redirect_uri='+redirectUri+'&response_type=token&scope=email'

newWin = window.open(url, 'vk-login', 'width=665,height=370')

And later you have two way to get email

  1. On redirect uri handler (server way)
  2. do redirect to any place of your site and every second check newWin.location.href a when it will be if (newHref.indexOf(redirectUri) != -1) then extract the parameter email (client way)
Brandiebrandise answered 29/4, 2016 at 7:19 Comment(0)
K
0

There is no way to do that. Vk is specific social network.

Ketchan answered 18/9, 2014 at 10:17 Comment(0)
H
0

you can use window.open

var url = 'https://oauth.vk.com/authorize?client_id=APP_ID&scope=email&redirect_uri=http://yoursite.com&response_type=token'

        var newWin = window.open(url, 'vk-login', 'width=665,height=370')
        newWin.onload = function() {
          var hash = newWin.location.hash
          console.log(hash)
        }
Homophone answered 27/1, 2017 at 10:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.