-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding bluebird missing tests * adding tests for async methods * #33 implementation including tests and updated README.md * adding error handling to samples * resolving conflict for README * update dependency versions * remove publisher and fix gulpfile * #24 first piece with tests to come: Reindeers & Requests implementation * solving #24, #40, #41, #42 - added all methods for #24 including tests - updated READMEs & example files - reworked entire testing architecture for #41 - removed deprecated methods for #42 - added scope checks for #40 * adding tests for #40 * sync updates from master * Added mechanism for token refresh (#47) * added token refresh functionality * added unit test for oauth.js * added unit test for oauthAsync.js * added tests for complete code coverage * code cleanup * Updating dependencies and set engines * Setting tokens to fix #39 * Added implicit surge handling (#49) * added functionality for surge pricing * added implicit surge handling * Changed OAuth2 urls to v2 (#53) * Adding tests for #53 * Dropping node v.1x/iojs in favor of ES6 #30
- Loading branch information
Showing
65 changed files
with
4,526 additions
and
1,785 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var Uber = require('node-uber'); | ||
|
||
// create new Uber instance | ||
var uber = new Uber({ | ||
client_id: 'YOUR CLIENT ID', | ||
client_secret: 'YOUR CLIENT SECRET', | ||
server_token: 'YOUR SERVER TOKEN', | ||
redirect_uri: 'http://localhost/callback', | ||
name: 'nodejs uber wrapper', | ||
language: 'en_US', | ||
sandbox: true | ||
}); | ||
|
||
// get authorization URL | ||
var authURL = uber.getAuthorizeUrl(['history', 'profile', 'request', 'places']); | ||
|
||
// redirect user to the authURL | ||
|
||
// the authorizarion_code will be provided via the callback after logging in using the authURL | ||
uber.authorizationAsync({ | ||
authorization_code: 'YOUR AUTH CODE' | ||
}) | ||
.spread(function(access_token, refresh_token, authorizedScopes, tokenExpiration) { | ||
// store the user id and associated access_token, refresh_token, scopes and token expiration date | ||
console.log('New access_token retrieved: ' + access_token); | ||
console.log('... token allows access to scopes: ' + authorizedScopes); | ||
console.log('... token is valid until: ' + tokenExpiration); | ||
console.log('... after token expiration, re-authorize using refresh_token: ' + refresh_token); | ||
|
||
// chain the promise to retrive all products for location | ||
return uber.products.getAllForLocationAsync(3.1357169, 101.6881501); | ||
}) | ||
.then(function(res) { | ||
// response with all products | ||
console.log(res); | ||
}) | ||
.error(function(err) { | ||
console.error(err); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.