Created
February 17, 2014 04:34
-
-
Save zaftzaft/9044781 to your computer and use it in GitHub Desktop.
Pocket の Access Token 取得するやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Get Pocket Access Token | |
* 2014/02/17 | |
*/ | |
var readline = require("readline"); | |
var qs = require("querystring"); | |
var request = require("request"); | |
var consumerKey = ""; | |
request.post({ | |
url: "https://getpocket.com/v3/oauth/request", | |
form: { | |
consumer_key: consumerKey, | |
redirect_uri: "http://localhost:8081/hoge" | |
} | |
}, function(err, resp, body){ | |
if(err){ throw err; } | |
var code = body.split("=")[1]; | |
console.log("https://getpocket.com/auth/authorize?request_token=" + code); | |
var rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
rl.question("And press enter After authentication", function(){ | |
getAccessToken(code); | |
rl.close(); | |
}); | |
}); | |
function getAccessToken(code){ | |
request.post({ | |
url: "https://getpocket.com/v3/oauth/authorize", | |
form: { | |
consumer_key: consumerKey, | |
code: code | |
} | |
}, function(err, resp, body){ | |
if(err){ throw err; } | |
console.log(qs.parse(body)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment