---
metadata:
  - name: generator
    content: Diplodoc Platform v5.44.0
alternate:
  - https://yandex.ru/dev/id/doc/en/suggest-connection.md
  - https://yandex.ru/dev/id/doc/ru/suggest-connection.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/id/doc/en/llms.txt

# Instant authorization setup

1. Configure the page of your website where the widget or button will enable the user to log in.

   1. Link the `sdk-suggest.js` script to the page:
      
      ```html
      <head>
         
      </head>
      ```
   
   1. Call the script. The code depends on the authorization component you select: the group of parameters determining the button's appearance is excluded for the widget.

      {% list tabs %}

      - Instant login widget

         ![](./_assets/has-cookie.png =400x)
      
         1. Copy this code:

            ```javascript
            YaAuthSuggest.init(
                  {
                     client_id: 'c46f0c53093440c39f12eff95a9f2f93',
                     response_type: 'token',
                     redirect_uri: 'https://examplesite.com/suggest/token'
                  },
                  'https://examplesite.com'
               )
               .then(({
                  handler
               }) => handler())
               .then(data => console.log('Message with a token', data))
               .catch(error => console.log('Error handling', error));
            ```

         1. In the code, substitute:

            * The `client_id` value with the ID of the OAuth app registered in [Step 1](https://yandex.ru/dev/id/doc/en/register-client.md).
            * The `redirect_uri` value with the URL of the auxiliary page you entered in the [**Redirect URI** field](https://yandex.ru/dev/id/doc/en/register-client.md#platforms) for the OAuth app that has this `client_id` (if you don't specify any URL, the first value from the **Redirect URI** field will be used).
            * `'https://examplesite.com'` with the "origin" of the auxiliary page that receives the token.

      - Login button

         1. Use the button generator to customize the button's appearance.

            {% include notitle [_](./_mdx/button-constructor.mdx) %}

         1. Copy the generated code and paste it into the page.

         1. In the code, substitute:

            * `oauthQueryParams` with the strings below.
               
               ```javascript
               {
                  client_id: 'c46f0c53093440c39f12eff95a9f2f93',
                  response_type: 'token',
                  redirect_uri: 'https://examplesite.com/suggest/token'
               }
               ```

               Use the following parameter values in these strings:
               
               * For `client_id` — the ID of the OAuth app registered in [Step 1](https://yandex.ru/dev/id/doc/en/register-client.md).
               * The `redirect_uri` value with the URL of the auxiliary page you entered in the [**Redirect URI** field](https://yandex.ru/dev/id/doc/en/register-client.md#platforms) for the OAuth app that has this `client_id` (if you don't specify any URL, the first value from the **Redirect URI** field will be used).

            * `tokenPageOrigin` with the "origin" of the callback page that receives the token.

      {% endlist %}

      See [Set up the sdk-suggest.js script for the authorization page](https://yandex.ru/dev/id/doc/en/suggest/script-sdk-suggest.md) to learn more about the `sdk-suggest.js` script.

1. Prepare an auxiliary page that will receive the OAuth token.

   1. Create a blank page at the address you entered in the **Redirect URI** field for the OAuth app registered in [Step 1](https://yandex.ru/dev/id/doc/en/register-client.md). You don't have to style the auxiliary page. It will only be displayed for a few milliseconds, so you can leave it blank.
   
   1. Link the `sdk-suggest-token.js` script to the page:
   
      ```html
      <head>
         
      </head>
      ```
  
   1. Call the script.

      1. Copy this code:

         ```javascript
         YaSendSuggestToken(
            'https://examplesite.com',{
               flag: true
            }
         )
         ```

      1. Replace `'https://examplesite.com'` in the code with the "origin" of your website's page where the widget or button will enable the user to log in.
      
   See [Set up the sdk-suggest-token.js script for the callback page](https://yandex.ru/dev/id/doc/en/suggest/script-sdk-suggest-token.md) to learn more about the `sdk-suggest-token.js` script.

{% included (./_mdx/button-constructor.mdx) %}
<!-- markdownlint-disable -->

<div class="ypd-preview">
    <a href="https://autofill.yandex.ru/suggest/button/constructor" target="_blank">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M18 19H6c-.55 0-1-.45-1-1V6c0-.55.45-1 1-1h5c.55 0 1-.45 1-1s-.45-1-1-1H5c-1.11 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-6c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55-.45 1-1 1zM14 4c0 .55.45 1 1 1h2.59l-9.13 9.13c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L19 6.41V9c0 .55.45 1 1 1s1-.45 1-1V3h-6c-.55 0-1 .45-1 1z"></path></svg>
    </a>
    <iframe src="https://autofill.yandex.ru/suggest/button/constructor" style="height: 500px"></iframe>
</div>

{% endincluded %}