From 99b95794c11111bbeb70d8b2d944471dde14f7b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Sun, 29 Aug 2021 02:59:48 +0200 Subject: Import node-node-rest-client_2.5.0-6.debian.tar.xz [dgit import tarball node-node-rest-client 2.5.0-6 node-node-rest-client_2.5.0-6.debian.tar.xz] --- changelog | 67 +++++++++++++++ control | 47 +++++++++++ copyright | 33 ++++++++ docs | 1 + gbp.conf | 5 ++ patches/fix-buffer-usage.diff | 34 ++++++++ patches/series | 1 + rules | 8 ++ salsa-ci.yml | 4 + source/format | 1 + tests/control | 6 ++ tests/nesttest | 12 +++ tests/nesttest_data/mock_nest_rest_server.py | 120 +++++++++++++++++++++++++++ tests/nesttest_data/nest_test.js | 64 ++++++++++++++ upstream/metadata | 4 + watch | 5 ++ 16 files changed, 412 insertions(+) create mode 100644 changelog create mode 100644 control create mode 100644 copyright create mode 100644 docs create mode 100644 gbp.conf create mode 100644 patches/fix-buffer-usage.diff create mode 100644 patches/series create mode 100755 rules create mode 100644 salsa-ci.yml create mode 100644 source/format create mode 100644 tests/control create mode 100755 tests/nesttest create mode 100755 tests/nesttest_data/mock_nest_rest_server.py create mode 100644 tests/nesttest_data/nest_test.js create mode 100644 upstream/metadata create mode 100644 watch diff --git a/changelog b/changelog new file mode 100644 index 0000000..1c7b887 --- /dev/null +++ b/changelog @@ -0,0 +1,67 @@ +node-node-rest-client (2.5.0-6) unstable; urgency=medium + + [ Debian Janitor ] + * Remove constraints unnecessary since buster: + + Build-Depends: Drop versioned constraint on node-debug. + + node-node-rest-client: Drop versioned constraint on node-debug in Depends. + * Update standards version to 4.5.1, no changes needed. + + -- Jelmer Vernooij Sun, 29 Aug 2021 01:59:48 +0100 + +node-node-rest-client (2.5.0-5) unstable; urgency=medium + + * Team upload + + [ Debian Janitor ] + * Set upstream metadata fields: Bug-Database, Bug-Submit. + + [ Xavier Guimard ] + * Bump debhelper compatibility level to 13 + * Use dh-sequence-nodejs + + [ Pirate Praveen ] + * Adapt for uuid 8.x API change (Closes: #964207) + + -- Pirate Praveen Tue, 08 Dec 2020 23:40:46 +0530 + +node-node-rest-client (2.5.0-4) unstable; urgency=medium + + * Team upload + + [ Debian Janitor ] + * Use secure copyright file specification URI. + * Bump debhelper from old 10 to 12. + * Set debhelper-compat version in Build-Depends. + * Set upstream metadata fields: Repository, Repository-Browse. + + [ Xavier Guimard ] + * Declare compliance with policy 4.5.0 + * Add "Rules-Requires-Root: no" + * Add debian/gbp.conf + * Update debian/watch to use npm registry + * Use pkg-js-tools auto install + * Replace Buffer() by Buffer.from() + + -- Xavier Guimard Sun, 01 Mar 2020 17:42:48 +0100 + +node-node-rest-client (2.5.0-3) unstable; urgency=low + + * Fix autopkgtest: node-node-uuid -> node-uuid (Closes: #913086) + * Bump Standards-Version to 4.2.1: nothing needs to be changed + * debian/control: Change Vcs-* to salsa + * Bump debhelper version to 10 + + -- Ying-Chun Liu (PaulLiu) Thu, 08 Nov 2018 06:32:44 +0800 + +node-node-rest-client (2.5.0-2) unstable; urgency=low + + * Fix autopkgtest fail + * Bump Standards-Version to 4.1.3: nothing needs to be changed + + -- Ying-Chun Liu (PaulLiu) Thu, 11 Jan 2018 18:25:06 +0800 + +node-node-rest-client (2.5.0-1) unstable; urgency=low + + * Initial release (Closes: #877646) + + -- Ying-Chun Liu (PaulLiu) Wed, 04 Oct 2017 16:36:24 +0000 diff --git a/control b/control new file mode 100644 index 0000000..544873b --- /dev/null +++ b/control @@ -0,0 +1,47 @@ +Source: node-node-rest-client +Maintainer: Debian Javascript Maintainers +Uploaders: Ying-Chun Liu (PaulLiu) +Section: javascript +Testsuite: autopkgtest-pkg-nodejs +Priority: optional +Build-Depends: + debhelper-compat (= 13) + , node-debug + , node-follow-redirects + , node-xml2js + , dh-sequence-nodejs +Standards-Version: 4.5.1 +Vcs-Browser: https://salsa.debian.org/js-team/node-node-rest-client +Vcs-Git: https://salsa.debian.org/js-team/node-node-rest-client.git +Homepage: https://github.com/aacerox/node-rest-client +Rules-Requires-Root: no + +Package: node-node-rest-client +Architecture: all +Depends: + ${misc:Depends} + , node-debug + , node-follow-redirects + , node-xml2js + , nodejs +Description: Rest API client for NodeJS + Allows connecting to any API REST and get results as js Object. The client + has the following features: + * Transparent HTTP/HTTPS connection to remote API sites. + * Allows simple HTTP basic authentication. + * Allows most common HTTP operations: GET, POST, PUT, DELETE, PATCH or any + other method through custom connect method + * Allows creation of custom HTTP Methods (PURGE, etc.) + * Direct or through proxy connection to remote API sites. + * Register remote API operations as own client methods, simplifying reuse. + * Dynamic path and query parameters and request headers. + * Improved Error handling mechanism (client or specific request) + * Added support for compressed responses: gzip and deflate + * Added support for follow redirects thanks to great follow-redirects + package + * Added support for custom request serializers (json,xml and url-encoded + included by default) + * Added support for custom response parsers (json and xml included by + default) + . + Node.js is an event-based server-side JavaScript engine. diff --git a/copyright b/copyright new file mode 100644 index 0000000..4476de2 --- /dev/null +++ b/copyright @@ -0,0 +1,33 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: node-rest-client +Upstream-Contact: https://github.com/aacerox/node-rest-client/issues +Source: https://github.com/aacerox/node-rest-client + +Files: * +Copyright: 2017 Alejandro Alvarez Acero +License: Expat + +Files: debian/* +Copyright: 2017 Ying-Chun Liu (PaulLiu) +License: Expat + +License: Expat + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + . + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/docs b/docs new file mode 100644 index 0000000..cdb5f04 --- /dev/null +++ b/docs @@ -0,0 +1 @@ +readme.md diff --git a/gbp.conf b/gbp.conf new file mode 100644 index 0000000..b713356 --- /dev/null +++ b/gbp.conf @@ -0,0 +1,5 @@ +[DEFAULT] +pristine-tar = True + +[import-orig] +filter = [ '.gitignore', '.travis.yml', '.git*' ] diff --git a/patches/fix-buffer-usage.diff b/patches/fix-buffer-usage.diff new file mode 100644 index 0000000..1877bc1 --- /dev/null +++ b/patches/fix-buffer-usage.diff @@ -0,0 +1,34 @@ +Description: replace Buffer() by Buffer.from() +Author: Xavier Guimard +Forwarded: no +Last-Update: 2020-03-01 + +--- a/lib/node-rest-client.js ++++ b/lib/node-rest-client.js +@@ -64,7 +64,7 @@ + var result ={}; + // if proxy requires authentication, create Proxy-Authorization headers + if (self.proxy.user && self.proxy.password){ +- result["Proxy-Authorization"] = "Basic " + new Buffer([self.proxy.user,self.proxy.password].join(":")).toString("base64"); ++ result["Proxy-Authorization"] = "Basic " + new Buffer.from([self.proxy.user,self.proxy.password].join(":")).toString("base64"); + } + // no tunnel proxy connection, we add the host to the headers + if(!self.useProxyTunnel) +@@ -497,7 +497,7 @@ + + // concurrent data chunk handler + res.on('data',function(chunk){ +- buffer.push(new Buffer(chunk)); ++ buffer.push(new Buffer.from(chunk)); + }); + + res.on('end',function(){ +@@ -583,7 +583,7 @@ + + // concurrent data chunk handler + res.on('data',function(chunk){ +- buffer.push(new Buffer(chunk)); ++ buffer.push(new Buffer.from(chunk)); + }); + + res.on('end',function(){ diff --git a/patches/series b/patches/series new file mode 100644 index 0000000..4012ed3 --- /dev/null +++ b/patches/series @@ -0,0 +1 @@ +fix-buffer-usage.diff diff --git a/rules b/rules new file mode 100755 index 0000000..218df65 --- /dev/null +++ b/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +%: + dh $@ diff --git a/salsa-ci.yml b/salsa-ci.yml new file mode 100644 index 0000000..33c3a64 --- /dev/null +++ b/salsa-ci.yml @@ -0,0 +1,4 @@ +--- +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml diff --git a/source/format b/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/tests/control b/tests/control new file mode 100644 index 0000000..d819997 --- /dev/null +++ b/tests/control @@ -0,0 +1,6 @@ +Tests: nesttest +Depends: @ + , node-uuid + , python3-flask + , python3-flask-restful +Restrictions: isolation-container, allow-stderr diff --git a/tests/nesttest b/tests/nesttest new file mode 100755 index 0000000..9db00f7 --- /dev/null +++ b/tests/nesttest @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +/sbin/start-stop-daemon --start --background --pidfile "$AUTOPKGTEST_TMP"/mock_nest_rest_server.pid --make-pidfile --startas `pwd`/debian/tests/nesttest_data/mock_nest_rest_server.py + +sleep 10 + +echo 'WN268AH3' | nodejs debian/tests/nesttest_data/nest_test.js + +sleep 10 + +/sbin/start-stop-daemon --stop --pidfile "$AUTOPKGTEST_TMP"/mock_nest_rest_server.pid --remove-pidfile --retry=TERM/30/KILL/5 diff --git a/tests/nesttest_data/mock_nest_rest_server.py b/tests/nesttest_data/mock_nest_rest_server.py new file mode 100755 index 0000000..75cf4bd --- /dev/null +++ b/tests/nesttest_data/mock_nest_rest_server.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 + +import flask +import flask_restful +from flask_restful import reqparse +import uuid + +fakepincode = 'WN268AH3' +accesstoken = 'c.fCJC0MzwLlj9mWVU8OsxYRw1OmHLyvUSarFx7wjYlDmx2B0p7Rlg8VcT8eiLtua0UwBWRhaOHCKkzgam0JwJv5AUTV2qinYWsSzLF9Qz8Py5KSwjyV4L2os2KlnkNebauMkXlmP1sfs8HdPc' +app = flask.Flask(__name__) +api = flask_restful.Api(app) + + +class GetFakePincode(flask_restful.Resource): + def get(self): + result = {'fakepincode': fakepincode} + return result + + def put(self): + parser = flask_restful.reqparse.RequestParser() + parser.add_argument('fakepincode') + args = parser.parse_args() + result = {'fakepincode': args['fakepincode']} + fakepincode = args['fakepincode'] + return result, 201 + +class AccessToken(flask_restful.Resource): + def post(self): + parser = flask_restful.reqparse.RequestParser() + parser.add_argument('code') + parser.add_argument('client_id') + parser.add_argument('client_secret') + parser.add_argument('grant_type') + args = parser.parse_args() + instanceID = str(uuid.uuid1()) + if (args['code'] != fakepincode): + result = { 'error': 'oauth2_error', + 'error_description': 'authorization code not found', + 'instance_id': instanceID } + return result,201 + result = {'access_token': accesstoken, 'expires_in': 315360000} + return result, 201 + +class ListCamera(flask_restful.Resource): + def get(self): + parser = flask_restful.reqparse.RequestParser() + parser.add_argument('Authorization', type=str, location='headers') + args = parser.parse_args() + print(args); + instanceID = str(uuid.uuid1()) + if (args['Authorization'] != 'Bearer '+accesstoken): + result = { 'error': 'unauthorized', + 'type': 'https://developer.nest.com/documentation/cloud/error-messages#auth-error', + 'message': 'unauthorized', + 'instance_id': instanceID } + return result,201 + + result = { + 'devices': { + 'cameras': { + '7lHyGwOIZ7bMmQPPVfYqs5PVlaoU3rx0wanU19-QRBSoK3DwZ1XaMw': { + 'name': 'Office', + 'software_version': '205-600055', + 'where_id': 'BRfAR8DqNjP4wgeCHJMXB6T8h5sM_oWcFbw4BdgS4lXxRlwbCdX9wQ', + 'device_id': '7lHyGwOIZ7bMmQPPVfYqs5PVlaoU3rx0wanU19-QRBSoK3DwZ1XaMw', + 'structure_id': 'T9L9obNI8LxtBghzreo0rj8VHxLowV0WPFpxpqhKygR--PRqEyT1DA', + 'is_online': 'true', + 'is_streaming': 'false', + 'is_audio_input_enabled': 'true', + 'last_is_online_change': '2017-09-27T16:28:18.000Z', + 'is_video_history_enabled': 'true', + 'is_public_share_enabled': 'true', + 'last_event': { + 'has_sound': 'false', + 'has_motion': 'true', + 'has_person': 'false', + 'start_time': '2017-09-27T16:27:43.410Z', + 'end_time': '2017-09-27T16:27:45.320Z', + 'urls_expire_time': '2017-10-07T16:27:43.410Z', + 'web_url': 'https://home.nest.com/cameras/CjY3bEh5R3dPSVo3Yk1tUVBQVmZZcXM1UFZsYW9VM3J4MHdhblUxOS1RUkJTb0szRHdaMVhhTXcSFmpSZlBmTnRnYVFBbkRPdmIyVEpPM0EaNkVycmw0a3pqMVZ3am15bnpQZlBHLVVtV1hqNmFIWmppY2FUTWdLcl9nY05abEpLTWVRM0ZfQQ/cuepoints/kfM23u5xqKPjz4mgo6oYfQ?auth=815fOF6Lsj2jLh_-xNglQuf5zt3OAh2M0MaGd9didhborxrTRiDAlKNnPBwmaN0innrbFj_zVjuw4zfxbCOh8fhpoc5D6hkglpEhHQAjyCT0Sjchwp3MB2a7dLlfr58a63X5dD3dRMtin8uGXSos98HpbAb68RaArXcoaRDR7nBnN43IWWjoYxx0ub-dssyR_iXq19rZZD3xfo', + 'app_url': 'nestmobile://cameras/CjY3bEh5R3dPSVo3Yk1tUVBQVmZZcXM1UFZsYW9VM3J4MHdhblUxOS1RUkJTb0szRHdaMVhhTXcSFmpSZlBmTnRnYVFBbkRPdmIyVEpPM0EaNkVycmw0a3pqMVZ3am15bnpQZlBHLVVtV1hqNmFIWmppY2FUTWdLcl9nY05abEpLTWVRM0ZfQQ/cuepoints/kfM23u5xqKPjz4mgo6oYfQ?auth=815fOF6Lsj2jLh_-xNglQuf5zt3OAh2M0MaGd9didhborxrTRiDAlKNnPBwmaN0innrbFj_zVjuw4zfxbCOh8fhpoc5D6hkglpEhHQAjyCT0Sjchwp3MB2a7dLlfr58a63X5dD3dRMtin8uGXSos98HpbAb68RaArXcoaRDR7nBnN43IWWjoYxx0ub-dssyR_iXq19rZZD3xfo', + 'image_url': 'https://www.dropcam.com/api/wwn.get_image/CjY3bEh5R3dPSVo3Yk1tUVBQVmZZcXM1UFZsYW9VM3J4MHdhblUxOS1RUkJTb0szRHdaMVhhTXcSFmpSZlBmTnRnYVFBbkRPdmIyVEpPM0EaNkVycmw0a3pqMVZ3am15bnpQZlBHLVVtV1hqNmFIWmppY2FUTWdLcl9nY05abEpLTWVRM0ZfQQ/xTXo_qxXgXUzVAcxyPsYWvyE8GP18NtW?auth=815fOF6Lsj2jLh_-xNglQuf5zt3OAh2M0MaGd9didhborxrTRiDAlKNnPBwmaN0innrbFj_zVjuw4zfxbCOh8fhpoc5D6hkglpEhHQAjyCT0Sjchwp3MB2a7dLlfr58a63X5dD3dRMtin8uGXSos98HpbAb68RaArXcoaRDR7nBnN43IWWjoYxx0ub-dssyR_iXq19rZZD3xfo', + 'animated_image_url': 'https://www.dropcam.com/api/wwn.get_animated_image/CjY3bEh5R3dPSVo3Yk1tUVBQVmZZcXM1UFZsYW9VM3J4MHdhblUxOS1RUkJTb0szRHdaMVhhTXcSFmpSZlBmTnRnYVFBbkRPdmIyVEpPM0EaNkVycmw0a3pqMVZ3am15bnpQZlBHLVVtV1hqNmFIWmppY2FUTWdLcl9nY05abEpLTWVRM0ZfQQ/xTXo_qxXgXUzVAcxyPsYWvyE8GP18NtW?auth=815fOF6Lsj2jLh_-xNglQuf5zt3OAh2M0MaGd9didhborxrTRiDAlKNnPBwmaN0innrbFj_zVjuw4zfxbCOh8fhpoc5D6hkglpEhHQAjyCT0Sjchwp3MB2a7dLlfr58a63X5dD3dRMtin8uGXSos98HpbAb68RaArXcoaRDR7nBnN43IWWjoYxx0ub-dssyR_iXq19rZZD3xfo' + }, + 'where_name': 'Office', + 'name_long': 'Office Camera', + 'web_url': 'https://home.nest.com/cameras/CjY3bEh5R3dPSVo3Yk1tUVBQVmZZcXM1UFZsYW9VM3J4MHdhblUxOS1RUkJTb0szRHdaMVhhTXcSFmpSZlBmTnRnYVFBbkRPdmIyVEpPM0EaNkVycmw0a3pqMVZ3am15bnpQZlBHLVVtV1hqNmFIWmppY2FUTWdLcl9nY05abEpLTWVRM0ZfQQ?auth=815fOF6Lsj2jLh_-xNglQuf5zt3OAh2M0MaGd9didhborxrTRiDAlKNnPBwmaN0innrbFj_zVjuw4zfxbCOh8fhpoc5D6hkglpEhHQAjyCT0Sjchwp3MB2a7dLlfr58a63X5dD3dRMtin8uGXSos98HpbAb68RaArXcoaRDR7nBnN43IWWjoYxx0ub-dssyR_iXq19rZZD3xfo', + 'app_url': 'nestmobile://cameras/CjY3bEh5R3dPSVo3Yk1tUVBQVmZZcXM1UFZsYW9VM3J4MHdhblUxOS1RUkJTb0szRHdaMVhhTXcSFmpSZlBmTnRnYVFBbkRPdmIyVEpPM0EaNkVycmw0a3pqMVZ3am15bnpQZlBHLVVtV1hqNmFIWmppY2FUTWdLcl9nY05abEpLTWVRM0ZfQQ?auth=815fOF6Lsj2jLh_-xNglQuf5zt3OAh2M0MaGd9didhborxrTRiDAlKNnPBwmaN0innrbFj_zVjuw4zfxbCOh8fhpoc5D6hkglpEhHQAjyCT0Sjchwp3MB2a7dLlfr58a63X5dD3dRMtin8uGXSos98HpbAb68RaArXcoaRDR7nBnN43IWWjoYxx0ub-dssyR_iXq19rZZD3xfo', + 'public_share_url': 'https://video.nest.com/live/w4o0ZjxQLX', + 'snapshot_url': 'https://www.dropcam.com/api/wwn.get_snapshot/CjY3bEh5R3dPSVo3Yk1tUVBQVmZZcXM1UFZsYW9VM3J4MHdhblUxOS1RUkJTb0szRHdaMVhhTXcSFmpSZlBmTnRnYVFBbkRPdmIyVEpPM0EaNkVycmw0a3pqMVZ3am15bnpQZlBHLVVtV1hqNmFIWmppY2FUTWdLcl9nY05abEpLTWVRM0ZfQQ?auth=815fOF6Lsj2jLh_-xNglQuf5zt3OAh2M0MaGd9didhborxrTRiDAlKNnPBwmaN0innrbFj_zVjuw4zfxbCOh8fhpoc5D6hkglpEhHQAjyCT0Sjchwp3MB2a7dLlfr58a63X5dD3dRMtin8uGXSos98HpbAb68RaArXcoaRDR7nBnN43IWWjoYxx0ub-dssyR_iXq19rZZD3xfo' + } + } + }, + 'structures': { + 'T9L9obNI8LxtBghzreo0rj8VHxLowV0WPFpxpqhKygR--PRqEyT1DA': { + 'name': 'Office1', + 'country_code': 'US', + 'postal_code': '35004', + 'time_zone': 'America/Chicago', + 'away': 'home', + 'structure_id': 'T9L9obNI8LxtBghzreo0rj8VHxLowV0WPFpxpqhKygR--PRqEyT1DA', + 'rhr_enrollment': 'false', + 'eta_begin': '1970-01-01T00:00:00.000Z', + } + }, + 'metadata': { + 'access_token': accesstoken, + 'client_version': 2, + 'user_id': 'z.1.1.5F24Y1m5X0WN0q1jnKSV/2RAcleKMzh7ase8Cs6Vpp8=' + } + } + return result, 201 + + +if __name__ == '__main__': + api.add_resource(GetFakePincode, '/fakepincode') + api.add_resource(AccessToken, '/oauth2/access_token') + api.add_resource(ListCamera, '/') + + app.run(port=14253) diff --git a/tests/nesttest_data/nest_test.js b/tests/nesttest_data/nest_test.js new file mode 100644 index 0000000..eebd8d7 --- /dev/null +++ b/tests/nesttest_data/nest_test.js @@ -0,0 +1,64 @@ +var Client = require('node-rest-client').Client; +const readline = require('readline'); +const { v1: uuidv1 } = require('uuid') + +const PRODUCTID='904b7e35-33c8-45c6-8fd1-f5807b68f8e6'; +const PRODUCTSECRET='bKN0NYfkkVHQx78A8rFCjS0z'; +const AUTHORIZATIONURL='https://home.nest.com/login/oauth2?client_id=PRODUCTID&state=STATE'; + +var CLIENTSTATE=uuidv1().replace(/-/g,''); +var PINCODE=''; +var ACCESSTOKEN=''; +//const NEST_API_URL = 'https://developer-api.nest.com'; +//const TOKEN_API_URL = 'https://api.home.nest.com/oauth2/access_token'; +const NEST_API_URL = 'http://localhost:14253'; +const TOKEN_API_URL = 'http://localhost:14253/oauth2/access_token'; + +console.log(AUTHORIZATIONURL.replace('STATE',CLIENTSTATE).replace('PRODUCTID',PRODUCTID)); + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +rl.question('PINCODE? ', (answer) => { + PINCODE = answer; + var client = new Client(); + var args = { + headers: { + "content-type": "application/x-www-form-urlencoded" + }, + parameters: { + code: PINCODE, + client_id: PRODUCTID, + client_secret: PRODUCTSECRET, + grant_type: 'authorization_code' + } + } + client.post(TOKEN_API_URL, args, function(data, response) { + ACCESSTOKEN = data.access_token; + + var client = new Client(); + var args = { + headers: { + "Authorization": 'Bearer ' + ACCESSTOKEN + } + }; + + client.get(NEST_API_URL, args, function (data, response) { + var cameras=data.devices.cameras; + + for (i=0; i