-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
36 lines (31 loc) · 1.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const Uber = require('node-uber');
const express = require('express')
const app = express()
const port = 3000;
const uber = new Uber({
client_id: 'replaceMe',
client_secret: 'replaceMe',
server_token: 'replaceMe',
redirect_uri: 'replaceMe ensure this matches redirect url in developer account config',
name: 'replaceMe ensure this matches name in developer account config',
language: 'en_US', // optional, defaults to en_US
sandbox: true // optional, defaults to false
});
app.get('/api/callback', function(request, response) {
uber.authorization({ authorization_code: request.query.code },
function (err, accessToken, refreshToken) {
if (err) {
throw err;
}
uber.user.getHistory(0, 50, function(err, response) {
console.log('response.history: ', response.history);
});
});
});
app.get('/api/login', function(request, response) {
const redirectUrl = uber.getAuthorizeUrl(['history_lite']);
response.redirect(redirectUrl);
});
app.listen(port, function () {
console.log(`http://localhost:${port}`);
})