When to use authorization in the skill

Using account linking, the skill can get access to information about the user's devices in your app and the ability to control them.

Linking accounts is always required to launch smart home skills. The user can't launch the skill until they link a Yandex account to their account in the smart home system of the skill owner (usually the device manufacturer).

Need to know

When to request authorization

Unlike generic skills, for smart home skills, you don't need:

  • To consider when to request authorization. The Alice app automatically does it before starting the skill.

  • To check whether the user is logged in when processing requests. Yandex Dialogs does this for you. If the user logs out of their account, requests stop being sent to devices. Alice asks the user to log in again.

Example

To voice-control Aqara smart devices, the user needs to:

  1. Download the Aqara Home app from Google Play or the App Store.

  2. Log in to the app, add Aqara smart devices, and set them up.

    Home management screen in the Aqara Home app

    Add device screen in the Aqara Home app

  3. Open the Home with Alice app and tap plusCreated with Sketch. in the upper-right corner.

  4. Choose Устройство умного дома (Smart home device) and then select an Aqara skill.

  5. Tap Привязать к Яндексу (Link to Yandex), which redirects the user to the Aqara Home app's authorization page that was specified in the skill settings in the Authorization URL field.

    Link Aqara and Yandex accounts screen

    Authorization screen in the Aqara Home app

  6. Log in to the Aqara Home app using the account from step 2 and tap Продолжить (Continue) to confirm Yandex Smart Home's access to the Aqara account.

    Aqara account access confirmation screen

    The OAuth 2.0 specification involves the following:

    1. The Aqara skill's authorization server calls the redirect URL (redirect endpoint), which returns the authorization confirmation code (authorization code grant).
    2. The Yandex Smart Home server sends a request to URL для получения токена (URL for getting a token) using the authorization code.
    3. The authorization server of the Aqara skill sends the user's OAuth token to Yandex Smart Home.

    For more information about authorization in the skill, see here.

When the user taps Обновить список устройств (Update a device list), the Yandex Smart Home server makes a request to the Aqara skill server on behalf of the user with the OAuth token. All devices from the Aqara Home app are added to the device list in the Home with Alice app.

Now, the user can simply command Alice to close the curtains, turn off the lights, or tell you the temperature and humidity in the room.

Useful links