-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthorize.js
40 lines (29 loc) · 1023 Bytes
/
authorize.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
37
38
39
40
(function() {
var app, consumer_key, express, path, pocket, succcess;
express = require('express');
path = require('path');
pocket = require('pocket-sdk');
consumer_key = '38055-419bdc12229496dfd282eb0d';
pocket.init(consumer_key, 'http://127.0.0.1:4000/pocket/callback');
succcess = function (ret, req, res) {
res.cookie('access_token', ret.access_token);
res.writeHead(302, {
Location: '/succcess'
});
return res.end();
}
app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
// routing
app.use(require('cookie-parser')());
app.use(pocket.oauth({ afterSuccess: succcess }));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/succcess', require('./routes/index'));
app.get('/', function(req, res) {
return res.redirect('/pocket/authorize');
});
app.listen(4000);
console.log('VISIT http://127.0.0.1:4000/');
}).call(this);