【问题标题】:Foursquare API, oauth, HTTP 301Foursquare API、oauth、HTTP 301
【发布时间】:2011-06-17 17:58:15
【问题描述】:

我正在使用 nodejs 中的foursquare api。 我按照here(Web 服务器应用程序)描述的步骤进行操作

但在最后一步中,当我获得授权代码时,我得到一个指向所请求的相同 url 的 HTTP 301。 我不知道为什么。

我错过了什么吗?

【问题讨论】:

    标签: oauth node.js foursquare


    【解决方案1】:

    你看过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 和 oauth v1
    【解决方案2】:

    我开始基于新的 4sq api (v2) 和 oauth2 实现自己的解决方案

    https://github.com/yikulju/Foursquare-on-node

    【讨论】:

    • 请更新您的链接,因为它现在处于离线状态,死链接会转到 github 404 页面。
    猜你喜欢
    • 2012-03-01
    • 2011-07-14
    • 1970-01-01
    • 1970-01-01
    • 2014-11-09
    • 2011-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多