K
K
Kirito Asumo2021-01-01 18:49:45
C++ / C#
Kirito Asumo, 2021-01-01 18:49:45

How to authorize VK in a user's browser and transfer an access key from it in C#?

I do authorization through Implicit Flow in VK.

In many applications, I saw that the user in the program clicks on the "Login through" button, after which an authorization link opens in his browser by default, where he confirms the authorization and the tab closes. And the access key is returned to the application.

Authorization goes through the following link:

https://oauth.vk.com/authorize?client_id={CLIENT_ID}&display=page&redirect_uri=https://oauth.vk.com/blank.html&scope=photos,wall&response_type=token&v=5.52&revoke=1


The bottom line is to open this link in the user's browser, where he will click "Allow" and he will be returned back to the application.

I saw options when the user is redirected to a stub page, where they simply return an access_token of the type through the application protocol: myApp://{"access_token": "waefsgg3waefwata34ssge"}

But how can I do it right? How are they implemented? At least a clue to a solution.

UPD: Dig towards the question "Communication between an external browser and the user's local application"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-01-01
@vabka

But how do you do it right? How are they implemented? At least a clue to a solution.

https://dev.vk.com/api/access-token/implicit-flow-...
If you log in to a browser application, you will have a redirect url to your web page from which you started authentication (there, through js, everything will be pulled out)
If it is necessary as in your example: myApp://{"access_token": "waefsgg3waefwata34ssge"}
Then it is called deeplink. It is done a little differently in different OSes, but in general it is done like this:
1. You make a desktop / mobile application
2. This application is somehow registered in the system as an application for processing some protocol in urls (for example, myApp). This usually happens when installing
3. Profit. When the browser tries to open such a URL, it will not be able to and will contact the OS - it will in turn pass this URL to your application.
On Windows, this is obviously done through the registry:
https://stackoverflow.com/questions/80650/how-do-i...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question