#002 — Smart Home Skills: OAuth for signing in
In this post, we will talk about using an existing OAuth 2 service provider with a Smart Home Skill.
Smart Home Skills are voice apps for Amazon’s Alexa platform, which help you control your Internet connected devices. This will be the first of many posts which explains the different things that go into creating a skill to control your smart home.
Amazon’s Alexa service allows one to use commands like the following —
- turn on the kitchen light
- set temperature to 25 degree Celsius
It also allows one to ask for information like —
- What’s the weather like in Pune, India?
- Did the Giants win last night?
The difference between the two types of interactions is that in the first case, we are asking Alexa to take actions which are specific to a user, whereas the in the second case we are asking for factual information available to everyone.
To enable Alexa to take actions on behalf of us, we have to link our account for the connected device that we will be using. Here’s an example of how your Skill will look after you enable account linking —
Here’s the definition of OAuth 2 as per RFC 6749 —
The OAuth 2.0 authorization framework enables a third-party application to obtain limited access to an HTTP service, either on behalf of a resource owner by orchestrating an approval interaction between the resource owner and the HTTP service, or by allowing the third-party application to obtain access on its own behalf.
A list of OAuth providers can be found on Wikipedia. We can potentially use any of the OAuth2 providers from that list, but for simplicity’s sake, let’s see how to use Amazon’s very own OAuth2 service called Login With Amazon(LWA).
- Create an account on developer.amazon.com
- Head over to Alexa Skills page — link
- Click on “Add a new skill” and select “Smart Home Skill API”
- Hitting next, will take you to a tab called Interaction Model. There should be a dialogue there which says that it has already been taken care of.
- After that, on the Configuration tab, you should see a section for “Account Linking”. This is where our Login With Amazon security profile credentials go.
- Read more from Amazon’s own blog post here to know more about the individual fields.
To receive updates, signup to our mailing list here !