Omniauth with FourSquare issue

2019-08-03 04:36发布

问题:

UPDATE 2011/05/01: I later carefully read through FourSquare's API document, and found it says:

(Note that the request parameters are not JSON, they are standard HTTP keys and values.) All authentication is via OAuth2, which means that all requests MUST be https.

Could this be the problem that I don't have a SSL connection in my development machine?


Hi all! I am trying to connect FourSquare via Omniauth, I followed the Railscast toturial below, and change the provider into foursquare. But the return is always "invalid_credentials". I googled around and find that there's a discussion about this on GitHub(links below), but seems no conclusion yet. Anyone has idea what went wrong?

Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, "XXXXXXX","XXXXXXX"
provider :foursquare, 'XXXXXXX',
'XXXXXXX'
end

RailsCast Link

Discussion on GitHub

回答1:

I have a gem which will work with omniauth for foursquare.

https://github.com/arunagw/omniauth-foursquare



回答2:

try to modify your provider initializer to point to your system's certificate path ("/etc/ssl/certs" on Ubuntu)

Rails.application.config.middleware.use OmniAuth::Builder do
    provider :twitter, "XXXXXXX","XXXXXXX"
    provider :foursquare, 'XXXXXXX', {:client_options => {:ssl => {:ca_path => "/etc/ssl/certs"}}}
end


回答3:

Your config looks fine, although you probably don't want to share your token/secret keys publicly.

Does the callback url that you used when registering your foursquare oauth consumer match the URL that you're testing with? If you used http://www.foo.com/auth/foursquare/callback when registering your consumer, but are testing on your dev environment (http://localhost:3000/..), you'll see that auth/failure error.



回答4:

Here's what I did: OmniAuth Invalid Response Error