-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDropBox.js
More file actions
39 lines (29 loc) · 1.03 KB
/
DropBox.js
File metadata and controls
39 lines (29 loc) · 1.03 KB
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
var dbox = require("dbox");
var config = require("./config");
var client = dbox.createClient({
app_key : config.DropBox.appKey, // required
app_secret : config.DropBox.appSecret,
root : "sandbox" // optional (defaults to sandbox)
});
var tokens = {};
module.exports = {
getTokenUrl: function(socket) {
client.request_token(function(status, reply){
console.log(reply);
tokens[reply.oauth_token] = reply.oauth_token_secret;
socket.set("dropboxAuth", reply, function() {});
socket.emit("dropboxAuth", {"status": status, "token": reply.oauth_token});
});
},
getAccessToken: function(oauth_token, socket) {
var options = {
"oauth_token": oauth_token, // required
"oauth_token_secret" : tokens[oauth_token], // required
};
client.access_token(options, function(status, reply){
tokens[reply.oauth_token] = reply.oauth_token_secret;
socket.set("dropboxAccess", reply, function() {});
socket.emit("dropboxAccess", {"status": status, "token": reply});
});
}
};