Som*_*gOn 5 twitter node.js twitter-oauth
我正在使用这个npm包对Twitter用户进行OAuth Echo验证:https://github.com/ciaranj/node-oauth
有没有人有一个如何使用此包来验证用户凭据的示例?
据我所知,我正在从iOS应用程序正确获取X-Auth-Service-Provider和X-Verify-Credentials-Authorization,但我在使用这个程序包时遇到问题.
这是OAuthEcho构造函数:
var oauthEcho = new OAuthEcho(
"https://twitter.com",
"https://api.twitter.com/1.1/account/verify_credentials.json",
app.config.twitter.consumer_key,
app.config.twitter.consumer_private_key,
"1.0A",
"HMAC-SHA1"
);
Run Code Online (Sandbox Code Playgroud)
真的很感激任何帮助!
谢谢!!
哇,我说这一切都错了.我实际上并不需要oauth模块.我需要请求模块对twitters api进行简单的GET调用.
// Setup the request object for OAuth Echo to twitter
var options = {
url: 'https://api.twitter.com/1.1/account/verify_credentials.json',
headers: {
'Authorization': req.headers['x-verify-credentials-authorization']
}
};
// Make the request
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
// If twitter responds with a 200, the echo call was authorized
// TODO: do stuff
next();
} else {
res.send(401, 'Unauthorized');
next();
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
990 次 |
| 最近记录: |