问题
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);
回答1:
There is no way to do that. Vk is specific social network. I have the same problem.
回答2:
When you get Access Token, VK also gives you Email and User ID, but you need specific permission for that - "email".
回答3:
vk.com now has that functionality. Try checking out this documentation page: https://vk.com/dev/permissions
回答4:
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
- On redirect uri handler (server way)
- 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)
回答5:
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)
}
来源:https://stackoverflow.com/questions/25528771/how-to-get-email-address-from-vk-api