From 25ae4e9c132d6e68ddb389808b8f22c8f43b17cd Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Mon, 14 Dec 2015 22:23:28 -0500 Subject: Begin rewrite for new OAuth API --- examples/oauth.js | 16 ++++++++++++++++ examples/sample_app.js | 14 -------------- 2 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 examples/oauth.js delete mode 100644 examples/sample_app.js (limited to 'examples') diff --git a/examples/oauth.js b/examples/oauth.js new file mode 100644 index 0000000..575d0d0 --- /dev/null +++ b/examples/oauth.js @@ -0,0 +1,16 @@ +var Active911 = require('../'); +var client = new Active911.RefreshClient('YOUR REFRESH TOKEN'); + +client.getAgency().then(function(agency) { + console.log(agency.name); + agency.devices.forEach(function(deviceInfo) { + client.getDevice(deviceInfo.id).then(function(device) { + console.log(device.name); + }).catch(function(err) { + console.log('Error retrieving device info for #' + deviceInfo.id); + }); + }); +}).catch(function(err) { + console.log('Error retrieving agency info:', err); +}); + diff --git a/examples/sample_app.js b/examples/sample_app.js deleted file mode 100644 index a08b039..0000000 --- a/examples/sample_app.js +++ /dev/null @@ -1,14 +0,0 @@ -var Active911 = require('../lib/active911').Active911; - -var oauth_id = '12345'; -var oauth_secret = 'asdf'; -var oauth_scope = 'read_agency read_alert read_device'; - -var api = new Active911(oauth_id, oauth_secret, oauth_scope); -var uri = api.getAuthorizationUri(); -console.log('Please go to ' + uri + ' to authenticate.'); - -api.ready(function() { - console.log('OAuth workflow complete'); - -}); -- cgit v1.2.3