Request an OAuth token in exchange for a confirmation code
If you use a confirmation code from the user to obtain an OAuth token, the authorization in your app should be performed in two steps:
-
Get a confirmation code from the user and pass it to Yandex OAuth.
-
Exchange the confirmation code for an OAuth token depending on the method of getting the confirmation code.
Tip
If you develop or test your app, you can use a debug token. No confirmation code is needed to get a debug token.
How to get a confirmation code
To get a confirmation code that can be exchanged for an OAuth token, choose one of the following methods:
-
If you can set up automatic extraction of information from URLs in your app, extract the confirmation code from the redirect URL:
Get a confirmation code from a URL -
If it's difficult to access URLs from your app, set up displaying the code on a page in a browser. This method is suitable for console apps when the user can open the browser and use the keyboard to enter the code they see:
Get a confirmation code from the user -
If no browser can be used on the device or entering codes is difficult, ask the user to enter the code on the Yandex OAuth authorization page. This method is suitable for apps that run on multimedia devices, such as Smart TV:
Enter the code on the Yandex OAuth authorization page