From bdba75452053791648ebd2e283fd87b637bade06 Mon Sep 17 00:00:00 2001 From: Don Boulia Date: Fri, 4 Dec 2020 14:19:07 -0500 Subject: [PATCH 1/4] fixes for latest blink API --- lib/blink.js | 266 ++++++++++++++++++--------------------- lib/blink_camera.js | 37 +++--- lib/blink_url_handler.js | 5 +- 3 files changed, 136 insertions(+), 172 deletions(-) diff --git a/lib/blink.js b/lib/blink.js index 554937f..8207b61 100644 --- a/lib/blink.js +++ b/lib/blink.js @@ -11,7 +11,7 @@ const { guid } = require('./util'); const request = require('request'); -function _statusCodeIsError(response){ +function _statusCodeIsError(response) { return response.statusCode < 200 || response.statusCode > 299 } module.exports = class Blink { @@ -76,55 +76,60 @@ module.exports = class Blink { for (var id in this._cameras) { if (this._cameras.hasOwnProperty(id)) { let camera = this._cameras[id]; - Object.keys(summaries).forEach(networkId => { - summaries[networkId].devices.forEach(device => { - if (device.device_id === camera.id) { - camera.update(device); - } - }); - }) + + summaries.cameras.forEach(device => { + if (device.id === camera.id) { + camera.update(device); + } + }); } } }); } + filterNetworks(array, index) { + const networks = this.networks.map(_ => _.id); + const result = []; + + array.forEach((el) => { + if (networks.includes(el[index])) { + result.push(el); + } + }); + + return result; + } + getSummary() { const promises = []; const networks = this.networks.map(_ => _.id); - networks.forEach(networkId => { - promises.push(new Promise((resolve, reject) => { - if (!this._auth_header) { - return reject(new BlinkException("Authentication token must be set")); + console.log('included networks: ' + JSON.stringify(networks)); + + return new Promise((resolve, reject) => { + if (!this._auth_header) { + return reject(new BlinkException("Authentication token must be set")); + } + + request({ + url: this.urls.home_url, + headers: this._auth_header, + json: true + }, (err, response, body) => { + + if (err || _statusCodeIsError(response)) { + return reject(new BlinkException(`Can't retrieve system summary`)); } - request({ - url: this.urls.network_url + networkId + "/homescreen", - headers: this._auth_header, - json: true - }, (err, response, body) => { - if (err || _statusCodeIsError(response)) { - return reject(new BlinkException(`Can't retrieve system summary`)); - } - return resolve(body); - }); - })); - }); + // filter based on networks that were selected - return Promise.all(promises) - .then(results => { - return results.reduce((acc, result, index) => { - acc[networks[index]] = result; - this._networks.forEach(network => { - if (network.id !== networks[index]) return; - network = { - ...network, - ...result, - }; - }); - return acc; - }, {}); + body.networks = this.filterNetworks(body.networks, 'id'); + body.sync_modules = this.filterNetworks(body.sync_modules, 'network_id'); + body.cameras = this.filterNetworks(body.cameras, 'network_id'); + + return resolve(body); }); + }); } getCameraThumbs() { @@ -133,93 +138,37 @@ module.exports = class Blink { var result = {}; for (var id in this._cameras) { if (this._cameras.hasOwnProperty(id)) { - result[id] = this._cameras.thumbnail; + result[id] = this._cameras[id].thumbnail; } } return result; }); } - getEvents(networkIds = []) { - const promises = []; - const networks = networkIds.length ? networkIds : this.networks.map(_ => _.id); - - networks.forEach(networkId => { - promises.push(new Promise((resolve, reject) => { - request({ - url: this.urls.event_url + networkId, - headers: this._auth_header, - json: true - }, (err, response, body) => { - if (err || _statusCodeIsError(response)) { - return reject(new BlinkException(`Can't retrieve system events`)); - } - this._events = body.event; - return resolve(this._events); - }); - })); - }); - - return Promise.all(promises) - .then(results => { - return results.reduce((acc, result, index) => { - acc[networks[index]] = result; - return acc; - }, {}); - }); - } - isOnline(networkIds = []) { - const promises = []; const networks = networkIds.length ? networkIds : this.networks.map(_ => _.id); - networks.forEach(networkId => { - promises.push(new Promise((resolve, reject) => { - request({ - url: this.urls.network_url + networkId + '/syncmodules', - headers: this._auth_header, - json: true - }, (err, response, body) => { - if (err || _statusCodeIsError(response)) { - return reject(new BlinkException(`Can't retrieve system status`)); - } - return resolve(body.syncmodule.status === 'online'); - }); - })); - }); - - return Promise.all(promises) - .then(results => { - return results.reduce((acc, result, index) => { - acc[networks[index]] = result; - return acc; - }, {}); - }); - } + return this.getSummary() + .then(summaries => { - getClients() { - return new Promise((resolve, reject) => { - request({ - url: this.urls.base_url + '/account/clients', - headers: this._auth_header, - json: true - }, (err, response, body) => { - if (err || _statusCodeIsError(response)) { - return reject(new BlinkException(`Can't retrieve connected clients`)); + const result = {}; + summaries.sync_modules.forEach((el) => { + if (networks.includes(el.network_id)) { + result[el.network_id] = (el.status === "online") ? true : false ; } - return resolve(body); }); + + return result; }); } getLastMotions() { - return this.getEvents() + return this.getVideos() .then(events => { var result = {}; events.forEach(event => { let camera_id = event.camera_id; - let camera = this._cameras[camera_id]; - + let camera = this._cameras[camera_id];sssssssssssss if (event.type === 'motion') { let url = this.urls.base_url + event.video_url; result[camera_id] = camera.motion = { @@ -236,10 +185,15 @@ module.exports = class Blink { isArmed() { return this.getSummary() .then(summaries => { - return Object.keys(summaries).reduce((acc, key) => { - acc[key] = summaries[key].network.armed; - return acc; - }, {}); + + const networks = this.networks.map(_ => _.id); + + const result = {}; + summaries.networks.forEach((el) => { + result[el.id] = el.armed; + }); + + return result; }); } @@ -250,8 +204,9 @@ module.exports = class Blink { networksToArm.forEach(networkId => { promises.push(new Promise((resolve, reject) => { let state = value ? 'arm' : 'disarm'; + console.log('arm url: ' + this.urls.arm_url + networkId + '/state/' + state); request.post({ - url: this.urls.network_url + networkId + '/' + state, + url: this.urls.arm_url + networkId + '/state/' + state, json: true, headers: this._auth_header, body: {} @@ -282,7 +237,7 @@ module.exports = class Blink { }, (err, response, body) => { if (err || _statusCodeIsError(response)) { return reject(new BlinkException(`Can't fetch videos`)); - } + } return resolve(body); }); }); @@ -291,17 +246,16 @@ module.exports = class Blink { getCameras() { return this.getSummary() .then(summaries => { - Object.keys(summaries).forEach(networkId => { - summaries[networkId].devices.forEach(device => { - if (device.device_type === 'camera') { - device.region_id = this._region_id; - device.network_id = networkId; - let newDevice = new BlinkCamera(device, this.urls); - this._cameras[newDevice.id] = newDevice; - this._idlookup[newDevice.id] = newDevice.name; - } - }); + + console.log('getCameras: ' + JSON.stringify(summaries.cameras)); + summaries.cameras.forEach(camera => { + camera.region_id = this._region_id; + + const newDevice = new BlinkCamera(camera, this.urls); + this._cameras[newDevice.id] = newDevice; + this._idlookup[newDevice.id] = newDevice.name; }); + return this._cameras; }); } @@ -315,35 +269,38 @@ module.exports = class Blink { let arm_url = network_id_url + '/camera/' + camera.id + '/'; camera.image_link = image_url; camera.arm_link = arm_url; + console.log("setting camera header " + this._auth_header); camera.header = this._auth_header; } } } setupSystem(name_or_id) { - if ( !((this._username && this._password) || (this._token && this._region_id ))) { + if (!((this._username && this._password) || (this._token && this._region_id))) { throw new BlinkAuthenticationException("(_username, _password) or (_token, _region_id) are required for system setup"); } - if(this._token){ + if (this._token) { this._setupWithToken() return this.getIDs(name_or_id) .then(this.getCameras.bind(this)) .then(this.getLinks.bind(this)); } - else{ + else { return this._getAuthToken() .then(this.getIDs.bind(this, name_or_id)) .then(this.getCameras.bind(this)) .then(this.getLinks.bind(this)); } } - _setupWithToken(){ - this._host = this._region_id + '.' + BLINK_URL; - this._auth_header = { - 'TOKEN_AUTH': this._token - }; - this.urls = new BlinkURLHandler(this._account_id, this._region_id); + + _setupWithToken() { + this._host = 'rest-' + this._region_id + '.' + BLINK_URL; + this._auth_header = { + 'token-auth': this._token + }; + this.urls = new BlinkURLHandler(this._account_id, this._region_id); } + _getAuthToken(repeats = 0) { return new Promise((resolve, reject) => { if (typeof this._username != 'string') { @@ -375,14 +332,14 @@ module.exports = class Blink { }; let authenticate = (response) => { - this._host = this._region_id + '.' + BLINK_URL; - this._token = response.authtoken.authtoken; + this._host = 'rest-' + this._region_id + '.' + BLINK_URL; this._auth_header = { - 'TOKEN_AUTH': this._token + 'token-auth': this._token }; this.urls = new BlinkURLHandler(this._account_id, this._region_id); + resolve(true); }; @@ -399,7 +356,7 @@ module.exports = class Blink { if (!this.auth_2FA) { if (repeats === 1) return reject(new BlinkAuthenticationException(`Authentication problem: verification timeout`)); return new Promise((resolve, reject) => { - setTimeout(() => { + setTimeout(() => { this._getAuthToken(repeats + 1).then(resolve, reject); }, this.verification_timeout); }).then(resolve, reject); @@ -409,24 +366,34 @@ module.exports = class Blink { output: process.stdout }); return rl.question(`Enter the verification code sent to ${this._username}: `, pin => { + this._region_id = body.region.tier; + this._region = body.region.code; + this._token = body.authtoken.authtoken; + + const urls = new BlinkURLHandler(body.account.id, body.region.tier); + headers['token-auth'] = body.authtoken.authtoken; + + console.log(`url: ${urls.base_url}/api/v4/account/${body.account.id}/client/${body.client.id}/pin/verify`); + console.log('headers: ' + JSON.stringify(headers)); + console.log('pin: ' + pin); + request.post({ - url: `${BASE_URL}/api/v4/account/${body.account.id}/client/${body.client.id}/pin/verify`, + url: `${urls.base_url}/api/v4/account/${body.account.id}/client/${body.client.id}/pin/verify`, json: true, headers: headers, body: { pin: `${pin}`, } }, (err, response, body) => { + console.log('response: ' + JSON.stringify(body)); + if (err || _statusCodeIsError(response)) { return reject(new BlinkAuthenticationException(`Authentication problem: ${body.message}`)); } - if (!body.region) { + if (!valid) { return reject(new BlinkAuthenticationException(`Authentication problem: ${body.message}`)); } - for (var key in body.region) { - this._region_id = key; - this._region = body.region[key]; - } + authenticate(body); }); rl.close(); @@ -435,10 +402,13 @@ module.exports = class Blink { if (!body.region) { return reject(new BlinkAuthenticationException(body.message)); } - for (var key in body.region) { - this._region_id = key; - this._region = body.region[key]; - } + + console.log('body: ' + JSON.stringify(body)); + + this._region_id = body.region.tier; + this._region = body.region.code; + this._token = body.authtoken.authtoken; + authenticate(body); } }); @@ -452,7 +422,7 @@ module.exports = class Blink { return reject(new BlinkException("You have to be authenticated before calling this method")); } request({ - url: this.urls.networks_url, + url: this.urls.home_url, headers: this._auth_header, json: true }, (err, response, body) => { @@ -461,7 +431,7 @@ module.exports = class Blink { } else { var network = false; if (typeof name_or_id != 'undefined') { - body.networks.forEach(function(n){ + body.networks.forEach(function (n) { if (n.id == name_or_id || n.name == name_or_id) { network = n; that._networks.push(network); @@ -480,8 +450,10 @@ module.exports = class Blink { }); } - that._account_id = that._networks[0].account_id; - that.urls = new BlinkURLHandler(that.accountId, that.regionId); + console.log('account: ' + JSON.stringify(body.account)); + + that._account_id = body.account.id; + that.urls = new BlinkURLHandler(that._account_id, that.regionId); return resolve(that); } }); diff --git a/lib/blink_camera.js b/lib/blink_camera.js index b771832..c3b0e12 100644 --- a/lib/blink_camera.js +++ b/lib/blink_camera.js @@ -8,23 +8,22 @@ const request = require('request'); module.exports = class BlinkCamera { constructor(config, urls) { this.urls = urls; - this._id = config.device_id; + this._id = config.id; this._name = config.name; - this._status = config.armed; + this._status = config.status; this._enabled = config.enabled; this._thumb = this.urls.base_url + config.thumbnail + '.jpg'; this._clip = this.urls.base_url + config.thumbnail + '.mp4'; - this._temperature = config.temp; + this._temperature = config.signals.temp; this._battery = config.battery; - this._notifications = config.notifications; this._motion = {}; this._header = null; this._image_link = null; this._arm_link = null; this._updated_at = config.updated_at; this._region_id = config.region_id; - this._wifi = null; - this._lfr = null; + this._wifi = config.signals.wifi; + this._lfr = config.signals.lfr; this._network_id = config.network_id; } @@ -92,14 +91,6 @@ module.exports = class BlinkCamera { this._battery = value; } - get notifications() { - return this._notifications; - } - - set notifications(value) { - this._notifications = value; - } - get image_link() { return this._image_link; } @@ -180,13 +171,12 @@ module.exports = class BlinkCamera { update(values) { this._name = values['name']; - this._status = values['armed']; + this._status = values['status']; this._enabled = values['enabled']; this._thumb = this.urls.base_url + values['thumbnail'] + '.jpg'; this._clip = this.urls.base_url + values['thumbnail'] + '.mp4'; - this._temperature = values['temp']; + this._temperature = values['signals'].temp; this._battery = values['battery']; - this._notifications = values['notifications']; this._updated_at = values['updated_at']; } @@ -200,11 +190,11 @@ module.exports = class BlinkCamera { if (err) { reject(new BlinkException(`Can't refresh thumbnail for camera ${this._id}:${this._name}`)); } else { - let devices = body.devices; - devices.forEach((device) => { - if (device.device_id === this._id) { - this._thumb = this.urls.base_url + device['thumbnail'] + '.jpg'; - this._updated_at = device['updated_at']; + let cameras = body.cameras; + cameras.forEach((camera) => { + if (camera.id === this._id) { + this._thumb = this.urls.base_url + camera['thumbnail'] + '.jpg'; + this._updated_at = camera['updated_at']; resolve(this._thumb); } }); @@ -234,6 +224,9 @@ module.exports = class BlinkCamera { fetchImageData() { return new Promise((resolve, reject) => { + console.log('thumbnail ' + this.thumbnail); + console.log('header ' + this._header); + request({ url: this.thumbnail, headers: this._header, diff --git a/lib/blink_url_handler.js b/lib/blink_url_handler.js index c0eb812..8015d79 100644 --- a/lib/blink_url_handler.js +++ b/lib/blink_url_handler.js @@ -5,10 +5,9 @@ module.exports = class BlinkURLHandler { constructor(account_id, region_id) { this.base_url = 'https://rest-' + region_id + '.' + BLINK_URL; - this.event_url = this.base_url + '/events/network/'; this.network_url = this.base_url + '/network/'; - this.networks_url = this.base_url + '/networks'; + this.arm_url = this.base_url + `/api/v1/accounts/${account_id}/networks/`; this.video_url = this.base_url + `/api/v1/accounts/${account_id}/media/changed`; - this.home_url = this.base_url + '/homescreen'; + this.home_url = this.base_url + '/api/v3/accounts/' + account_id + '/homescreen'; } }; From 3a87e4bee9def1c7fe3d137f6cb1846c8171306a Mon Sep 17 00:00:00 2001 From: Don Boulia Date: Tue, 29 Dec 2020 09:16:59 -0500 Subject: [PATCH 2/4] comment out debug messages --- lib/blink.js | 20 ++++++++++---------- lib/blink_camera.js | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/blink.js b/lib/blink.js index 8207b61..65d8996 100644 --- a/lib/blink.js +++ b/lib/blink.js @@ -104,7 +104,7 @@ module.exports = class Blink { const promises = []; const networks = this.networks.map(_ => _.id); - console.log('included networks: ' + JSON.stringify(networks)); + // console.log('included networks: ' + JSON.stringify(networks)); return new Promise((resolve, reject) => { if (!this._auth_header) { @@ -204,7 +204,7 @@ module.exports = class Blink { networksToArm.forEach(networkId => { promises.push(new Promise((resolve, reject) => { let state = value ? 'arm' : 'disarm'; - console.log('arm url: ' + this.urls.arm_url + networkId + '/state/' + state); + // console.log('arm url: ' + this.urls.arm_url + networkId + '/state/' + state); request.post({ url: this.urls.arm_url + networkId + '/state/' + state, json: true, @@ -247,7 +247,7 @@ module.exports = class Blink { return this.getSummary() .then(summaries => { - console.log('getCameras: ' + JSON.stringify(summaries.cameras)); + // console.log('getCameras: ' + JSON.stringify(summaries.cameras)); summaries.cameras.forEach(camera => { camera.region_id = this._region_id; @@ -269,7 +269,7 @@ module.exports = class Blink { let arm_url = network_id_url + '/camera/' + camera.id + '/'; camera.image_link = image_url; camera.arm_link = arm_url; - console.log("setting camera header " + this._auth_header); + // console.log("setting camera header " + this._auth_header); camera.header = this._auth_header; } } @@ -373,9 +373,9 @@ module.exports = class Blink { const urls = new BlinkURLHandler(body.account.id, body.region.tier); headers['token-auth'] = body.authtoken.authtoken; - console.log(`url: ${urls.base_url}/api/v4/account/${body.account.id}/client/${body.client.id}/pin/verify`); - console.log('headers: ' + JSON.stringify(headers)); - console.log('pin: ' + pin); + // console.log(`url: ${urls.base_url}/api/v4/account/${body.account.id}/client/${body.client.id}/pin/verify`); + // console.log('headers: ' + JSON.stringify(headers)); + // console.log('pin: ' + pin); request.post({ url: `${urls.base_url}/api/v4/account/${body.account.id}/client/${body.client.id}/pin/verify`, @@ -385,7 +385,7 @@ module.exports = class Blink { pin: `${pin}`, } }, (err, response, body) => { - console.log('response: ' + JSON.stringify(body)); + // console.log('response: ' + JSON.stringify(body)); if (err || _statusCodeIsError(response)) { return reject(new BlinkAuthenticationException(`Authentication problem: ${body.message}`)); @@ -403,7 +403,7 @@ module.exports = class Blink { return reject(new BlinkAuthenticationException(body.message)); } - console.log('body: ' + JSON.stringify(body)); + // console.log('body: ' + JSON.stringify(body)); this._region_id = body.region.tier; this._region = body.region.code; @@ -450,7 +450,7 @@ module.exports = class Blink { }); } - console.log('account: ' + JSON.stringify(body.account)); + // console.log('account: ' + JSON.stringify(body.account)); that._account_id = body.account.id; that.urls = new BlinkURLHandler(that._account_id, that.regionId); diff --git a/lib/blink_camera.js b/lib/blink_camera.js index c3b0e12..7d4176d 100644 --- a/lib/blink_camera.js +++ b/lib/blink_camera.js @@ -224,8 +224,8 @@ module.exports = class BlinkCamera { fetchImageData() { return new Promise((resolve, reject) => { - console.log('thumbnail ' + this.thumbnail); - console.log('header ' + this._header); + // console.log('thumbnail ' + this.thumbnail); + // console.log('header ' + this._header); request({ url: this.thumbnail, From 9f8f99b231438f563690c3fd9d2f781abaa357c7 Mon Sep 17 00:00:00 2001 From: Don Boulia Date: Sun, 28 Mar 2021 17:06:59 -0400 Subject: [PATCH 3/4] changes for v5 login --- lib/blink.js | 27 ++++++++++++++------------- lib/constants.js | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/blink.js b/lib/blink.js index 65d8996..4075cc1 100644 --- a/lib/blink.js +++ b/lib/blink.js @@ -322,7 +322,7 @@ module.exports = class Blink { "password": this._password, "notification_key": notification_key, "unique_id": this._device_id, - "app_version": "6.0.7 (520300) #afb0be72a", + "app_version": "6.0.12", "client_name": this.device_name, "client_type": "android", "device_identifier": this._device_id, @@ -352,7 +352,7 @@ module.exports = class Blink { if (err || _statusCodeIsError(response)) { return reject(new BlinkAuthenticationException(`Authentication problem: ${body.message}`)); } else { - if ((body.client || {}).verification_required) { + if ((body.account || {}).account_verification_required) { if (!this.auth_2FA) { if (repeats === 1) return reject(new BlinkAuthenticationException(`Authentication problem: verification timeout`)); return new Promise((resolve, reject) => { @@ -366,19 +366,19 @@ module.exports = class Blink { output: process.stdout }); return rl.question(`Enter the verification code sent to ${this._username}: `, pin => { - this._region_id = body.region.tier; - this._region = body.region.code; - this._token = body.authtoken.authtoken; + this._region_id = body.account.tier; + this._region = body.account.region; + this._token = body.auth.token; - const urls = new BlinkURLHandler(body.account.id, body.region.tier); - headers['token-auth'] = body.authtoken.authtoken; + const urls = new BlinkURLHandler(body.account.account_id, body.account.tier); + headers['token-auth'] = body.auth.token; - // console.log(`url: ${urls.base_url}/api/v4/account/${body.account.id}/client/${body.client.id}/pin/verify`); + // console.log(`url: ${urls.base_url}/api/v4/account/${body.account.account_id}/client/${body.account.client_id}/pin/verify`); // console.log('headers: ' + JSON.stringify(headers)); // console.log('pin: ' + pin); request.post({ - url: `${urls.base_url}/api/v4/account/${body.account.id}/client/${body.client.id}/pin/verify`, + url: `${urls.base_url}/api/v4/account/${body.account.account_id}/client/${body.acount.client_id}/pin/verify`, json: true, headers: headers, body: { @@ -399,15 +399,16 @@ module.exports = class Blink { rl.close(); }); } - if (!body.region) { + if (!body.account.region) { + console.log('body ', body); return reject(new BlinkAuthenticationException(body.message)); } // console.log('body: ' + JSON.stringify(body)); - this._region_id = body.region.tier; - this._region = body.region.code; - this._token = body.authtoken.authtoken; + this._region_id = body.account.tier; + this._region = body.account.region; + this._token = body.auth.token; authenticate(body); } diff --git a/lib/constants.js b/lib/constants.js index 521ac55..92e9d89 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -4,7 +4,7 @@ global.BLINK_URL = 'immedia-semi.com'; global.LOGIN_URL = 'https://rest-prod.' + BLINK_URL + '/api/v3/login'; -global.LOGIN_URL_2FA = 'https://rest-prod.' + BLINK_URL + '/api/v4/account/login'; +global.LOGIN_URL_2FA = 'https://rest-prod.' + BLINK_URL + '/api/v5/account/login'; global.BASE_URL = 'https://rest-prod.' + BLINK_URL; global.DEFAULT_URL = 'prod.' + BLINK_URL; global.SIZE_NOTIFICATION_KEY = 152; From 5a7afbefc32a818d3e7317a9405bf5b8590ff9f7 Mon Sep 17 00:00:00 2001 From: Don Boulia Date: Sat, 12 Jun 2021 08:04:08 -0400 Subject: [PATCH 4/4] Set account_id from response body --- lib/blink.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/blink.js b/lib/blink.js index 4075cc1..858fa7c 100644 --- a/lib/blink.js +++ b/lib/blink.js @@ -332,6 +332,8 @@ module.exports = class Blink { }; let authenticate = (response) => { + // console.log('auth response: ', response); + this._host = 'rest-' + this._region_id + '.' + BLINK_URL; this._auth_header = { @@ -369,7 +371,9 @@ module.exports = class Blink { this._region_id = body.account.tier; this._region = body.account.region; this._token = body.auth.token; - + this._account_id = body.account.account_id; + + console.log('body.account.account_id', body.account.account_id); const urls = new BlinkURLHandler(body.account.account_id, body.account.tier); headers['token-auth'] = body.auth.token; @@ -409,6 +413,7 @@ module.exports = class Blink { this._region_id = body.account.tier; this._region = body.account.region; this._token = body.auth.token; + this._account_id = body.account.account_id; authenticate(body); } @@ -428,6 +433,7 @@ module.exports = class Blink { json: true }, (err, response, body) => { if (err || _statusCodeIsError(response)) { + console.log('error ', body); return reject(new BlinkException(`Can't retrieve system status`)); } else { var network = false;