10
votes

I'm trying to get Facebook authentication working with Devise through omniauth-facebook, I've followed the instructions here: https://github.com/plataformatec/devise/wiki/OmniAuth%3a-Overview

When I follow the login with Facebook link I am redirected to Facebook to login and accept the requested permissions.

I am then taken back to /users/sign_in with the error message "Could not authorize you from Facebook because "Invalid credentials""

Looking at the server logs the redirect comes from "/users/auth/facebook/callback?code=[long text string]" which is being processed with Users::OmniauthCallbacksController#failure rather than Users::OmniauthCallbacksController#facebook as I would have expected if it had worked.

Any suggestions as to why this is happening and how to resolve it much appreciated.

2
facing the same problem, only some of the users get the error.amitkaz
I have the same problem after updating omniauth, but only with chrome in non-incognito. My own facebook user is rejected in my everyday chrome, even though I tried to clear it of cookies etc. Safari, FF and chrome-incognito works fine. (I don't know if other users have this problem as I haven't released yet)Jeppe Liisberg

2 Answers

4
votes

Ok, I had the very same issue. The reason for me turned out that I had defined this line in config/initializers/devise.rb:

config.omniauth :facebook ...

The app id and app secret were defined for my test Facebook app, and for production one. Fixing those id:s now fixed the problem.

0
votes

facebook changes protocol from oauth to oauth2 the main difference that credentials (id, token, name..) now packaged into one hash. You should parse.