-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfbsetup.js
executable file
·45 lines (35 loc) · 1.03 KB
/
fbsetup.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
#!/usr/bin/env node
"use strict";
const graph = require('fbgraph'),
readline = require('readline'),
jsonfile = require('jsonfile')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
console.log("Let's get authenticated!")
const conf = jsonfile.readFileSync("config.json")
const authenticationURL = graph.getOauthUrl({
"client_id": conf.client_id,
"redirect_uri": conf.redirect_uri,
})
console.log("Visit this URL in your web browser:")
console.log(authenticationURL)
rl.question("Enter the code received:\n", code => {
graph.authorize({
"client_id": conf.client_id,
"redirect_uri": conf.redirect_uri,
"client_secret": conf.client_secret,
"code": code
}, function (err, facebookRes) {
rl.close()
if (err !== null) {
console.log("Encountered an error")
console.log(err)
return
}
conf.access_token = facebookRes.access_token
console.log("Got access token! Writing config...")
jsonfile.writeFileSync("config.json", conf)
});
})