J
J
jenya77712018-10-09 13:41:44
In contact with
jenya7771, 2018-10-09 13:41:44

How to get a VK token?

Hello, I am writing a nodeJS application and I need to get a user authorization token. He must click on the link on the page:

https://oauth.vk.com/authorize?client_id=000000&scope=groups,wall,offline,photos&redirect_uri=http://oauth.vk.com/blank.html&display=page&v=5.21&response_type=token

And then he logs in and is transferred back to the site.
The question is whether to make the button just a link, or is it better to make a POST form, after which the application itself will redirect it to the link.
And what redirect should be after? a link with a token, for example /vk/{checkToken}#access_token=12345, where I will create a checkToken, and after the transition I will understand which user completed the procedure for obtaining the token. Or just do /vk/{idUser}#access_token=12345?
How to make it more correct and safer?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2018-10-09
@jenya7771

After authorization and transfer to the http://oauth.vk.com/blank.htmlc token in the hash, you can only pull it out by being "above" the user's browser. A Web extension installed in the user's browser or your entire application on some Electron with a browser component will be able to receive such data. There is no way to do this in a regular browser: someone else's domain.
On the second question. Having a token, you can get the user id by calling the method users.get()with this token: it will return the data of the user who issued the token.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question