forked from filefog/filefog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
access_token_generator.js
100 lines (89 loc) · 3.62 KB
/
access_token_generator.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
delete require.cache[require.resolve("./lib/main.js")]
var FileFog = require("./lib/main.js")
//The following are test keys for a FileFog Integration Test applications. Please don't (ab)use these keys are they are used for automated testing.
//If you want to use your own set of access tokens within the test harness you can generate them with this file, just modify the FileFog.provider('box') line.
FileFog.setConfig({
google : {
client_key : '777041726477-a5o1tp6f3i9m1me3tj5vhpnrn1jge43c.apps.googleusercontent.com',
client_secret : 'mWURYHmMKZxr6aeR7DTjRu-q',
client_scope : "https://www.googleapis.com/auth/drive"
},
skydrive : {
client_key : '000000004C10EA03',
client_secret : 'YfSMQ7El6nN5hotB4zDKtrpishCd1P4M',
client_scope : "wl.basic wl.emails wl.offline_access wl.skydrive_update"
},
box : {
client_key : 'cch3sssk23ueqsbdh2k2zlv2i7rz06lp',
client_secret : '6v7ywbCdut5FRdIjDeREofrFGc2ymGmA'
},
dropbox : {
client_key : 'sl47p7pijvtp73h',
client_secret : 'j6vluc5yq7dxnj6'
}
});
var provider_options = { redirect_url :function (service){
var service_name = service.toLowerCase();
if(service_name == "skydrive")
return "http://www.example.edu/service/callback/skydrive";
else
return 'http://localhost:3000/service/callback/' + service_name
}
}
var readline = require('readline')
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
////########################### Dropbox ###################################
//
//var PROVIDER_NAME = "dropbox"
//var provider = FileFog.provider(PROVIDER_NAME,provider_options);
//
//console.log('Visit the url: ', provider.oAuthGetAuthorizeUrl());
//rl.question('Enter the code here:', function(code){
// provider.oAuthGetAccessToken(code).then(function(access_tokens){
// var utility = require('./test/utility.js');
// utility.saveAccessToken(PROVIDER_NAME,access_tokens);
// console.log(access_tokens)
// })
//});
//
////########################### Google ###################################
//
//var PROVIDER_NAME = "google"
//var provider = FileFog.provider(PROVIDER_NAME,provider_options);
//
//console.log('Visit the url: ', provider.oAuthGetAuthorizeUrl());
//rl.question('Enter the code here:', function(code){
// provider.oAuthGetAccessToken(code).then(function(access_tokens){
// var utility = require('./test/utility.js');
// utility.saveAccessToken(PROVIDER_NAME,access_tokens);
// console.log(access_tokens)
// })
//});
////
////########################### Skydrive ###################################
//
//var PROVIDER_NAME = "skydrive"
//var provider = FileFog.provider(PROVIDER_NAME,provider_options);
//
//console.log('Visit the url: ', provider.oAuthGetAuthorizeUrl());
//rl.question('Enter the code here:', function(code){
// provider.oAuthGetAccessToken(code).then(function(access_tokens){
// var utility = require('./test/utility.js');
// utility.saveAccessToken(PROVIDER_NAME,access_tokens);
// console.log(access_tokens)
// })
//});
//########################### box ###################################
var PROVIDER_NAME = "box"
var provider = FileFog.provider(PROVIDER_NAME,provider_options);
console.log('Visit the url: ', provider.oAuthGetAuthorizeUrl());
rl.question('Enter the code here:', function(code){
provider.oAuthGetAccessToken(code).then(function(access_tokens){
var utility = require('./test/utility.js');
utility.saveAccessToken(PROVIDER_NAME,access_tokens);
console.log(access_tokens)
})
});