php – Error Code 17: Validation required (VK API)

Question:

After receiving the code from VK, I receive an access_token .

https://oauth.vk.com/access_token?client_id=%s&client_secret=%s&code=%s&redirect_uri=%s

After that, I try to get data from the user

https://api.vk.com/method/users.get?user_id=".$data-user_id."&access_token=token&fields=photo_50&v=5.68

But at this point, VK returns error # 17:

object(stdClass)#2 (1) {
["error"]=>
object(stdClass)#18 (4) {
["error_code"]=>
int(17)
["error_msg"]=>
string(65) "Validation required: please open redirect_uri in browser 95232901"

["redirect_uri"]=>
string(69) "https://m.vk.com/login?act=security_check&api_hash=4a959bd2a476aea3fc"
}
}

But, if I take public data that does not require a key, then everything is fine

https://api.vk.com/method/users.get?user_id=".$data-user_id."&fields=photo_50&v=5.68

In general, the error crashes when I try to take user data with an access key.


https://vk.com/dev/need_validation

The following parameter is also passed in the error message: redirect_uri is a specially composed address that must be opened in a browser to pass the validation procedure.

But the problem is that when the user is thrown by the link in redirect_uri , he clicks the "confirm validation" button, and after that VK throws the user here

VK automatically checks the user through a JS script, and sends it to the final link:

https://oauth.vk.com/blank.html#success=1&access_token=fsdf312fds4213321f&user_id=12345

And there is no back_url to my site , but I need to read the access_token and user_id . How to do this if VK has already sent the user to the verification page, and then to another address?

Answer:

redirect_uri is the address to which the user will be returned after following this link and confirming. If successful, it will be returned to this link along with the code with which you can get the token. (The server must contact for the token)

Actually, all this is in the VK documentation with examples and transmitted parameters

Scroll to Top
AllEscort