N
N
Nicholas2015-08-17 09:59:24
In contact with
Nicholas, 2015-08-17 09:59:24

How to get the user's access_token to work with it from the server?

I can't figure out how to get the user's access_token for the server!
I created applications in VK and when loading I get data:

http://мой сайт ру/social_api/index.html?api_url=http://api.vk.com/api.php&api_id=4656995&api_settings=9255&viewer_id=18601455&viewer_type=2&sid=39d0333ffdc54596841e8a0141ec04cf6bddfkdcc9dace6b5f646f112d96049ab45e087f08cdecbecf0efd&secret=b443998c65&access_token=32cc547e6e8f0ed1225e0beda38f63705a300fad9fe8541e7b8d25ea955b1497168c53b83737e703dbc2be2&user_id=18601455&group_id=0&is_app_user=1&auth_key=deac02f02ea4d9e25k56f5d3ae1394420&language=0&parent_language=0&ad_info=ElsdCQBUR1VlAQFeAkwJSXHt5BkQ8HTJXUVBBJRVBNwoIFjI2HA8E&is_secure=0&ads_app_id=4656995_d1kff23be7203289290&referrer=user_apps&lc_name=19950c48&hash=

there is a token here: 32cc547e6e8f0ed1225e0beda38f63705a300fad9fe8541e7b8d25ea955b1497168c53b83737e703dbc2be2
user id 18601455
with this token I can send a request from the browser and get the correct response from the VK server
Example:
api.vk.com/method/friends.get?uid=18601455&access_token=32cc547e6e8f0ed1225e0beda38f63705a300fad9fe8541e7b8d25ea955b1497168c53b83737e703dbc2be2

BUT! if the request is made from the server, then we get an error:
User authorization failed: access_token was given to another ip address
And the question is how to get a user token to work with it from the server?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
wiygn, 2015-08-17
@wiygn

In the scope, ask for "offline" permission, then the token will be "eternal" and is not bound to IP.
Messages and wall.post methods are only accessible from a redirect to blank.html, i.e. receiving through the standard oAuth flow (giving the code to the server, and receiving the token from the server by the code) you will not receive them.

A
ar4ebaldello, 2015-08-17
@ar4ebaldello

"access_token of the user for the server" - there is no such thing. There is a token for the client, and it must remain with the client. There is a token for the server, but not all methods are available for it.
Here's how to get a server token.

S
SystemOMG, 2015-08-24
@SystemOMG

You can get it on your server, only through a login and password

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question