When to use authorization in a skill
When accounts are linked, the skill can access information about user devices on your service and manage them.
Linking accounts is always required to launch smart home skills. The user can't launch a skill until they connect their Yango account to the account in the smart home management system of the skill owner (usually the device manufacturer).
Need to know
You can publish only skills that use OAuth 2.0 authorization with authorization code grants.
The authorization server can be either part of your smart device data server, or an independent service.
When to require authorization
Unlike generic skills, for smart home skills, you don't need:
To consider when to request authorization. The Yango Play app automatically does it before starting the skill.
To check whether the user is signed in when processing requests. Yango Dialogs do this for you. If the user logs out of their account, requests stop being sent to devices. Yasmina asks the user to sign in again.
Example
For example, to control Aqara smart devices with voice, the user needs to:
- Download the Aqara Home app from Google Play or the App Store.
Log in to the app, then add and configure Aqara smart devices.
- Open the Yango Play app and tap in the upper-right corner.
- Choose Smart home device, and then select an Aqara skill.
Tap Link to Yango. This redirects to the Aqara Home authorization page that was specified in the skill settings in Authorization URL.
- Log in to the Aqara Home app with the account from Step 2 and tap Continue to confirm Yango Smart Home access to the Aqara account. Here's what happens according to the OAuth 2.0 specification:
- The Aqara skill authorization server calls the redirect URL (redirect endpoint) that returns an authorization confirmation code (authorization code grant).
- The Yango Smart Home server sends a request to Get token URL using the authorization code.
- The Aqara skill authorization server sends the user's OAuth token to Yango Smart Home.
When the user taps Update device list, the Yango Smart Home server sends a request with the issued OAuth token to the Aqara skill server on behalf of the user. All devices from the Aqara Home app are added to the Yango Play app device list.
After that, the user can just ask Yasmina to close the curtains, turn off the lights, or tell them the temperature or humidity in the room.