Library: auth_keys

From Yombo
Jump to: navigation, search
auth keys
Commonly Used Yes
Status Active

Summary
Access tokens are used to connect to the Gateway API without having to use login credentials.

Introduction

Authentication Keys (authkeys) can be created by modules or users to allow access to the Yombo Gateway API to avoid using login credentials. This allows devices to be controlled and monitored by external scripts and applications.

See also

Use Cases

Users

Users can manage authentication keys using the web interface.

Modules

Modules can request authentication keys to be created so that various outside resources can access the system. For example, the Amazon Alexa module creates an AuthKey so that Alexa can send device commands to the Yombo Gateway. See Usage section below.

Hooks

No hooks registered.

Usage

To create an authentication key, there are two to three steps to complete: 1) Create the authentication key; 2) Assign a role to it; and optionally 3) Assign permissions to the role.

Step 1: Create authkey

A new authkey can be quickly created. To prevent creating multiple authentication keys, it's best to check if the authkey already exists and use that.

 1 try:
 2     self.authkey = self._AuthKeys.get('Amazon Alexa')
 3     self.authkey.enable()
 4 except KeyError:
 5     self.authkey = yield self._AuthKeys.new({
 6         "label": "Amazon Alexa",
 7         "description": "Automatically generated by the the Amazon Alexa module."
 8                     " This allows Alexa to send the gateway commands and get status updates.",
 9         "preserve_key": True,
10         "created_by": "alexa module",
11         "created_by_type": "module",
12         }
13     )

Step 2: Attach auth key to a role

In order for the authentication key to do anything, it must be attached to a Role.

-To be completed once implementation is complete in v.0.24.0-


This page was last edited on 10 November 2019.