Problem
I have Devise Omniauth-Facebook authentication. The log in with facebook works, but the Session is lost when the user goes to localhost:3000
.
I have the following GEMs:
Devise 4.2.0
Rails 5
omniauth 1.4.0
omniauth-facebook 4.0.0
omniauth-oauth2 1.4.0
Description
The Session works correctly for users not authenticated with Omniauth-Facebook,
This is my devise.rb
omniauth-facebook settings:
config.omniauth :facebook, "APP_ID", "APP_SECRET", callback_url: "http://127.0.0.1:3000/users/auth/facebook/callback", scope: 'public_profile, email', image_size: 'large', provider_ignores_state: true
I already tried the following solution that did not work:
- turning off protect_from_forgery
- OmniAuth.config.full_host = "http://127.0.0.1:3000"
- Following the accepted solution of Jeroen van Dijk at the following post:
Devise and OmniAuth remembering OAuth
For this solution, in my rake routes I do not have the path
user_oauth_connect_path
, even if I added the route inroutes.rb
. I also think this is not the solution to my problem because I have Devise 4.2.0 and Rails 5 - @user.remember_me = true
All the previous solutions were taken from the following stackoverflow discussions:
Omniauth+Facebook lost session
Devise and OmniAuth remembering OAuth
The code is the standard one included in the guides from github of Devise and omniauth-facebook Thanks a lot for your help Fabrizio Bertoglio