Skip to content

Device Registration

Don Park edited this page Sep 29, 2017 · 8 revisions

New Device Registration

Location records in IceCondor are created per-device. A device has a token that allows a client to authenticate and write new entries.

Creating a device is a matter of issuing an "auth.email" message with a device id (user generated) and receiving a device secret (server generated) via email, and hashing the two to create an device key. In the conversation below, fill in your email and the device_id with any unique string starting with "device-". (Note that json messages must be contained to a single line)

On websocket connection, icecondor says hello. Use any websocket tool.

$ ./wscat wss://api.icecondor.com/v2
connected to wss://api.icecondor.com/v2
{"id":"018835a2","method":"hello","params":{"name":"mx.icecondor.com","version":"2-0317ba0"}}

Send the auth.email message to associate a device id to your account/email address. ("id" field is part of RPC can be any value)

< {"id":"123","method":"auth.email","params":{"email":"icecondor@docs.example", "device_id":"device-2017jul10-sample"}}
> {"id":"123","result":{"status":"OK"}}

Look in your inbox for subject "IceCondor Phone Activation Link". The link in the body of the email contains the device key.

https://icecondor.com/auth/device_key-f80cce20-6680-11e7-b663-0b1c838574f1

Now we have both pieces, the device id and secret. Use sha256 on the device id + device secret base64 encode the result to get the device key.

$ irb
irb(main):001:0> require 'digest'
irb(main):003:0> dId = "device-2017jul10-sample"
irb(main):003:0> dSecret = "device_key-f80cce20-6680-11e7-b663-0b1c838574f1"
irb(main):008:0> Digest::SHA2.base64digest(dId+dSecret)
=> "LCj8F8X6LVc22s4HvYg4NdpugayXnBYQGw/nC3HHzRo="

The device key can be used to authenticate to icecondor using an auth.session message as follows:

Authentication

< {"id":"0","method":"auth.session","params":{"device_key":"LCj8F8X6LVc22s4HvYg4NdpugayXnBYQGw/nC3HHzRo="}}
> {"id":"0","result":{"user":{"id":"c0b190d2-ed9c-4346-be43-2084ad041fca"}}}

Websocket tool

A websocket tool is available in this repo as wscat.

$ git clone https://github.com/icecondor/api ; cd api
$ npm install
$ ./wscat wss://api.icecondor.com/v2
connected to wss://api.icecondor.com/v2
{"id":"f651d790","method":"hello","params":{"name":"mx.icecondor.com","version":"2-undefined"}}

Another option is wsd written in go.

$ mkdir websockettool; cd websockettool
$ GOPATH=`pwd` go get github.com/alexanderGugel/wsd
$ ./bin/wsd -insecureSkipVerify -url wss://api.icecondor.com/v2
connecting to wss://api.icecondor.com/v2 from http://localhost/...
successfully connected to wss://api.icecondor.com/v2

< {"id":"c68790c1","method":"hello","params":{"name":"mx.icecondor.com","version":"2-undefined"}}
>
Clone this wiki locally