Omniauth 与 foursquare :获取“.../auth/foursquare/callback?code=XXXX”反而
我正在尝试使用 OmniAuth 与 foursquare 连接。我按照RailsCast: 241: Simple OmniAut中的说明进行操作。
我停在使用 SessionController 在 YAML 中引发响应的部分, 并将代码部署到 Heroku (我发现使用本地计算机根本不起作用)。
但是,我没有看到 YAML 结构化页面,而是得到了 URL:
http ://XX-sunset-XX.heroku.com/auth/foursquare/callback?code=10LBOAEUQQNRZ01CLRYUC0FBFZAFGFYUDVOGVE51HO3BZBXX
,其中显示一个页面(HTML 格式,我认为是Heroku 的默认错误处理):
We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.
这是怎么回事?
下面是来自 Heroku 的跟踪:
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]: Started GET "/test/index" for 211.23.144.132 at Wed Jun 01 01:18:59 -0700 2011
2011-06-01T08:18:59+00:00 app[web.1]: Processing by TestController#index as HTML
2011-06-01T08:18:59+00:00 app[web.1]: Rendered test/index.html.erb within layouts/application (2.3ms)
2011-06-01T08:18:59+00:00 app[web.1]: Completed 200 OK in 3ms (Views: 3.0ms | ActiveRecord: 0.0ms)
2011-06-01T08:18:59+00:00 heroku[router]: GET simple-sunset-248.heroku.com/test/index dyno=web.1 queue=0 wait=0ms service=11ms bytes=1603
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]: Started GET "/stylesheets/all.css" for 211.23.144.132 at Wed Jun 01 01:18:59 -0700 2011
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]: ActionController::RoutingError (No route matches "/stylesheets/all.css"):
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 heroku[router]: GET simple-sunset-248.heroku.com/stylesheets/all.css dyno=web.1 queue=0 wait=0ms service=5ms bytes=922
2011-06-01T01:19:00-07:00 heroku[nginx]: GET /stylesheets/all.css HTTP/1.1 | 211.23.144.132 | 953 | http | 404
2011-06-01T08:19:04+00:00 app[web.1]:
2011-06-01T08:19:04+00:00 app[web.1]:
2011-06-01T08:19:04+00:00 app[web.1]: Started GET "/auth/foursquare" for 211.23.144.132 at Wed Jun 01 01:19:04 -0700 2011
2011-06-01T08:19:04+00:00 heroku[router]: GET simple-sunset-248.heroku.com/auth/foursquare dyno=web.1 queue=0 wait=0ms service=6ms bytes=1032
2011-06-01T01:19:05-07:00 heroku[nginx]: GET /auth/foursquare HTTP/1.1 | 211.23.144.132 | 1062 | http | 302
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 app[web.1]: Started GET "/auth/foursquare/callback?code=4GU3FEFI2Z3JB40ZDZC5EFOF2XG2LOAKRZJWQY041CDDJ5XS" for 211.23.144.132 at Wed Jun 01 01:19:14 -0700 2011
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 app[web.1]: OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 heroku[router]: GET simple-sunset-248.heroku.com/auth/foursquare/callback dyno=web.1 queue=0 wait=0ms service=15ms bytes=934
2011-06-01T01:19:15-07:00 heroku[nginx]: GET /auth/foursquare/callback?code=4GU3FEFI2Z3JB40ZDZC5EFOF2XG2LOAKRZJWQY041CDDJ5XS HTTP/1.1 | 211.23.144.132 | 965 | http | 500
I am trying to use OmniAuth to connect with foursquare. I followed the instruction in RailsCast: 241: Simple OmniAut.
I stopped at the part where using a SessionController to raise response in YAML,
and deploy the codes to Heroku (I found using the local machine won't work at all).
However, instead of seeing a YAML structured page, I get the URL:
http ://XX-sunset-XX.heroku.com/auth/foursquare/callback?code=10LBOAEUQQNRZ01CLRYUC0FBFZAFGFYUDVOGVE51HO3BZBXX
with a page that shows (HTML format, I think it's Heroku's default error handling):
We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.
What's going on?
Below is the trace from Heroku:
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]: Started GET "/test/index" for 211.23.144.132 at Wed Jun 01 01:18:59 -0700 2011
2011-06-01T08:18:59+00:00 app[web.1]: Processing by TestController#index as HTML
2011-06-01T08:18:59+00:00 app[web.1]: Rendered test/index.html.erb within layouts/application (2.3ms)
2011-06-01T08:18:59+00:00 app[web.1]: Completed 200 OK in 3ms (Views: 3.0ms | ActiveRecord: 0.0ms)
2011-06-01T08:18:59+00:00 heroku[router]: GET simple-sunset-248.heroku.com/test/index dyno=web.1 queue=0 wait=0ms service=11ms bytes=1603
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]: Started GET "/stylesheets/all.css" for 211.23.144.132 at Wed Jun 01 01:18:59 -0700 2011
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]: ActionController::RoutingError (No route matches "/stylesheets/all.css"):
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 app[web.1]:
2011-06-01T08:18:59+00:00 heroku[router]: GET simple-sunset-248.heroku.com/stylesheets/all.css dyno=web.1 queue=0 wait=0ms service=5ms bytes=922
2011-06-01T01:19:00-07:00 heroku[nginx]: GET /stylesheets/all.css HTTP/1.1 | 211.23.144.132 | 953 | http | 404
2011-06-01T08:19:04+00:00 app[web.1]:
2011-06-01T08:19:04+00:00 app[web.1]:
2011-06-01T08:19:04+00:00 app[web.1]: Started GET "/auth/foursquare" for 211.23.144.132 at Wed Jun 01 01:19:04 -0700 2011
2011-06-01T08:19:04+00:00 heroku[router]: GET simple-sunset-248.heroku.com/auth/foursquare dyno=web.1 queue=0 wait=0ms service=6ms bytes=1032
2011-06-01T01:19:05-07:00 heroku[nginx]: GET /auth/foursquare HTTP/1.1 | 211.23.144.132 | 1062 | http | 302
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 app[web.1]: Started GET "/auth/foursquare/callback?code=4GU3FEFI2Z3JB40ZDZC5EFOF2XG2LOAKRZJWQY041CDDJ5XS" for 211.23.144.132 at Wed Jun 01 01:19:14 -0700 2011
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 app[web.1]: OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 app[web.1]:
2011-06-01T08:19:14+00:00 heroku[router]: GET simple-sunset-248.heroku.com/auth/foursquare/callback dyno=web.1 queue=0 wait=0ms service=15ms bytes=934
2011-06-01T01:19:15-07:00 heroku[nginx]: GET /auth/foursquare/callback?code=4GU3FEFI2Z3JB40ZDZC5EFOF2XG2LOAKRZJWQY041CDDJ5XS HTTP/1.1 | 211.23.144.132 | 965 | http | 500
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不使用 Ruby 或 Ruby on Rails,但我可以告诉您,foursquare 似乎没有实现 OAuth 2.0标准以标准方式,即根据Foursquare 开发 OAuth 文档。它没有使用许多已实现的 OAuth 库所使用的标准参数,例如“
client_ID
”v.“oauth_consumer_key
”。您在上面看到的是,您发送了请求(如其文档中所述),要求“
response_type=code
”,该请求将返回到您的回调 URI,参数为“code=4GU3FEFI2Z3JB40ZDZC5EFOF2XG2LOAKRZJWQY041CDDJ5XS< /code>”,然后您需要对其进行解析并发送回以获取 API 调用所需的访问令牌。
在文档中的 Ajax 示例中,它显示您可以使用“
response_type=token
”,它将在响应中提供“access_token=ACCESS_TOKEN
”作为参数。我希望这会有所帮助。祝你好运。
I don't use Ruby or Ruby on Rails, but I can tell you that it appears foursquare did not implement the OAuth 2.0 standard in a standard way, that is, according to the OAuth documentation in Foursquare Dev OAuth Doc. It's not using standard parameters that many implemented OAuth libraries are using, for example, "
client_ID
" v. "oauth_consumer_key
".What you're seeing above is that you sent your request (as it says in their documentation) asking for "
response_type=code
" which returns to your callback URI with parameter "code=4GU3FEFI2Z3JB40ZDZC5EFOF2XG2LOAKRZJWQY041CDDJ5XS
" which you then need to parse and send back to get the access token you need for API calls.Further in the documentation, in the Ajax example, it shows you can use "
response_type=token
" which will give an "access_token=ACCESS_TOKEN
" as a parameter in the response.I hope this helps a bit. Good luck.