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);

5 Answers5

7

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

Andrey Banshchikov
  • 1,558
  • 2
  • 15
  • 27
  • 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. :) – Mr.TK Sep 19 '16 at 19:08
1

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

Simon
  • 39
  • 2
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)
Vasiliy Mazhekin
  • 688
  • 8
  • 24
0

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

double-beep
  • 5,031
  • 17
  • 33
  • 41
funivan
  • 3,323
  • 1
  • 14
  • 19
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)
        }
Emir Mamashov
  • 1,108
  • 9
  • 14