K
K
k0nsu12017-06-20 16:12:42
In contact with
k0nsu1, 2017-06-20 16:12:42

Working with vk api without authorization?

Good day comrades, I'm trying to get the user id on the site, in response I get status: "not_authorized"

<script src="https://vk.com/js/api/openapi.js?146" type="text/javascript"></script>
<script type="text/javascript">

function checkVk() {
    VK.init({
        apiId: '*****'
    });
    function authInfo(response) {
    	console.log(response);
        if (response.session) {
            console.log(response.session.mid);
            alert(response.session.mid);
        }
    }
    console.log(VK.Auth.getLoginStatus(authInfo));
}
checkVk();

</script>

With method
VK.Api.call('users.get', {}, function(r) {
  	if(r.response) {
    alert('Привет, ' + r.response[0].first_name + ' '+ r.response[0].last_name);
  }
});

The situation is the same, although the documentation says that you can get data without authorization, tell me what's the matter? Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Serezha, 2017-06-20
Ahen @Ahen

Some fairy tales, VK will never give away user data without his (the user's) consent. You need to ask for authorization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question