2011-06-01 36 views
-1

我試圖使用OmniAuth連接foursquare。我遵循RailsCast: 241: Simple OmniAut中的說明。Omniauth與foursquare:獲取「.../auth/foursquare/callback?code = XXXX」而不是

我停在那裏的部分使用SessionController提高在YAML, 響應和部署代碼Heroku(我發現使用本地機器將無法在所有的工作)。

然而,而不是看到YAML結構的網頁,我得到的網址:

HTTP://XX-sunset-XX.heroku.com/auth/foursquare/callback碼= 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 link

下面是從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 
+0

你能給我們堆棧跟蹤嗎?這是否在開發中發生?如果你直接開發到Heroku,我不會那樣做。使用rails開發服務器可以獲得更好的日誌。 – 2011-06-01 06:31:22

+0

這可能是愚蠢的問,但我真的是一個ROR新手。我如何獲得堆棧跟蹤?我應該從本地開發服務器或heroku獲取它嗎?我知道使用本地開發環境總是很好玩,但是我根本無法讓開發環境中的FourSquare Oauth工作。一位朋友告訴我,如果它在真正的服務器上,它可能會工作。 – 2011-06-01 06:50:26

+0

本地開發服務器,你應該有更好的時間讓它在那裏工作。 – 2011-06-01 07:02:16

回答

1

我不on Rails的使用Ruby和Ruby,但我可以告訴你,它Foursquare的出現並沒有實現OAuth 2.0標準一種標準的方式,也就是根據Foursquare Dev OAuth Doc中的OAuth文檔。它沒有使用許多實現的OAuth庫正在使用的標準參數,例如,「client_ID」v。「oauth_consumer_key」。

你上面看到的是你發送了你的請求(就像它在文檔中說的)請求「response_type=code」,它返回到你的回調URI並帶有參數「code=4GU3FEFI2Z3JB40ZDZC5EFOF2XG2LOAKRZJWQY041CDDJ5XS」,然後你需要解析併發送回獲取API調用所需的訪問令牌。

此外,在文檔中的Ajax示例中,它顯示您可以使用「response_type=token」,它將在響應中給出「access_token=ACCESS_TOKEN」作爲參數。

我希望這會有所幫助。祝你好運。