Token Based Authentication

Channel Token Based Authentication provides read and write access to a specific channel: the one the token is associated to.

Beebotte associates a Token to every created channel. This token can be used to authenticate read and write operations on that channel. Channel Token authentication uses either:

  • REST API through HTTP Authorization header
  • REST API through token query parameter
  • Beebotte Websocket Connection
  • Beebotte MQTT Connection
Channel Tokens generated after June 1 2018 are prefixed with token_. We recommend switching to this token format. You can regenerate new tokens for your channels as described here.
Token authentication using Authorization Header example:
POST /v1/data/write/demo/resource1 HTTP/1.1
Content-Type: application/json
Date: Mon, 07 Oct 2013 14:04:50 GMT
host: beebotte.com
X-Auth-Token: 1234567890

{"data":"37","ts":1400761008646}

Token authentication using token query parameter example:
POST /v1/data/write/demo/resource1?token=1234567890 HTTP/1.1
Content-Type: application/json
Date: Mon, 07 Oct 2013 14:04:50 GMT
host: beebotte.com

{"data":"37","ts":1400761008646}

Beebotte SDKs:
//Include the Beebotte SDK for nodejs
var bbt = require('beebotte');

var bclient = new bbt.Connector({token: 'CHANNEL_TOKEN'});
# Include the Beebotte SDK for Python
from beebotte import *

bclient = BBT(token = "CHANNEL_TOKEN")

Websocket (Socketio) Connection:
//Include the Beebotte SDK for nodejs
var bbt = require('beebotte');
bclient = bbt.Stream({transport: {
  type: 'socketio',
  token: 'CHANNEL_TOKEN'
})

MQTT Connection:

You can use Beebotte Nodejs SDK to connect to Beebotte using MQTT as follows:

//Include the Beebotte SDK for nodejs
var bbt = require('beebotte');
bclient = bbt.Stream({transport: {
  type: 'mqtt',
  token: 'CHANNEL_TOKEN'
})

If you are using an MQTT client library, provide CHANNEL_TOKEN as username and leave the password blank.

If the Channel token was generated before June 1 2018, you need to prefix it with token: like token:channel_token_content.