#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.

Account Linking

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 —

Check out the top right corner of the Yeelight connected LED lights Smart Home Skill

OAuth 2

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).

  1. Create an account on developer.amazon.com
  2. Head over to Alexa Skills page — link
  3. Click on “Add a new skill” and select “Smart Home Skill API”
  4. 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.
  5. 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.
  6. 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 !