Requesting an OAuth token using the confirmation code

If you use the confirmation code from the user to get an OAuth token, app authorization must have two stages:

  1. Receiving a confirmation code from the user and passing the code to Yandex OAuth.

  2. Exchanging a confirmation code for an OAuth token depending on the method for obtaining the verification code.

Tip

If you are developing or testing the app, you can use a debug token. You don't need a verification code to get a debug token.

How to get a confirmation code

To request a confirmation code to exchange for an OAuth token, choose one of the following methods:

  • If you can set up the app to receive information from the URL automatically, get the confirmation code from the redirect URL:
    Getting a confirmation code from a URL

  • If it's difficult to get the redirect URL in the app, request the code output on the browser page. The method is good for console apps, when the user has access to the browser and can use the keyboard to enter the code they received:
    Receiving a confirmation code from the user

  • If the user can't use a browser or it's difficult to enter a code on the device, you can ask the user to enter the code in Yandex OAuth. The method is good for apps launched on multimedia devices, such as Smart TV:
    Entering the code on the authorization page Yandex OAuth

Tip

You can design the link for obtaining an OAuth token in the page HTML code as a button with the Yandex logo.

You can customize the button to match the style of your website or app. Learn more.