【发布时间】:2011-06-17 17:58:15
【问题描述】:
我正在使用 nodejs 中的foursquare api。 我按照here(Web 服务器应用程序)描述的步骤进行操作
但在最后一步中,当我获得授权代码时,我得到一个指向所请求的相同 url 的 HTTP 301。 我不知道为什么。
我错过了什么吗?
【问题讨论】:
标签: oauth node.js foursquare
我正在使用 nodejs 中的foursquare api。 我按照here(Web 服务器应用程序)描述的步骤进行操作
但在最后一步中,当我获得授权代码时,我得到一个指向所请求的相同 url 的 HTTP 301。 我不知道为什么。
我错过了什么吗?
【问题讨论】:
标签: oauth node.js foursquare
你看过connect-auth吗?不错的库,还支持foursquare。
安装:
npm install oauth connect-auth
使用尝试:
varfoursquareConsumerKey = ""; varfoursquareConsumerSecret = "";
app.get ('/auth/foursquare', function(req, res, params) {
req.authenticate(['foursquare'], function(error, authenticated) {
res.writeHead(200, {'Content-Type': 'text/html'})
if( authenticated ) {
res.end("<html><h1>Hello foursquare user:" + JSON.stringify( req.getAuthDetails().user ) + ".</h1></html>")
}
else {
res.end("<html><h1>Foursquare authentication failed :( </h1></html>")
}
});
})
我想你的代码一定是这样的,但我还没有尝试过,因为我没有foursquare帐户。
【讨论】:
我开始基于新的 4sq api (v2) 和 oauth2 实现自己的解决方案
【讨论】: