Devise omniauth-facebook redirect_uri isn't an absolute URI

343 views
Skip to first unread message

fabrizio bertoglio

unread,
Mar 2, 2017, 5:46:55 AM3/2/17
to Ruby on Rails: Talk

thanks a lot for the advise. I migrated to Heroku and I have the following problem with facebook omniauth authentication. When I authenticate with facebook the callback URL does not work and I get sent to the homepage https://barteringapps.herokuapp.com/#_=_ with the following log error message :

"redirect_uri isn't an absolute URI. Check RFC 3986.","type":"OAuthException","code":191,"fbtrace_id":"BT1wrRRo64m" method=GET path="/" host=barteringapps.herokuapp.com request_id=8913218f-703d-4da0-9388-f59d3a97bb69 fwd="81.171.81.200" dyno=web.1 connect=0ms service=11ms status=200 bytes=13425


In development the functionality works when I set callback-url in devise.rb and in the facebook App settings to http://127.0.0.1:5000/users/auth/facebook/callback

So to give a more detailed log (I omitted not important infos):

  1. I click on the link for the sign in

    method=GET path="/users/sign_in" host=barteringapps.herokuapp.com fwd="81.171.81.200" status=200

  2. I click for the sign in with facebook

    method=GET path="/users/auth/facebook" host=barteringapps.herokuapp.com fwd="81.171.81.200" status=302 INFO -- omniauth: (facebook) Request phase initiated.

  3. Callback from facebook, I notice that the path does not include my host

    method=GET path="/users/auth/facebook/callback?code='sometoken'" host=barteringapps.herokuapp.com fwd="81.171.81.200"

I already searched Stackoverflow for a solution and I followed this instructions Devise omniauth-facebook redirect_uri Url must absolute

  1. I added :client_options
  2. I configured the absolute path like so in devise.rb

    callback_url: ENV['SERVER_ROOT']+'/users/auth/facebook/callback'

  3. In heroku settings I added the SERVER_ROOT env variable

I have also the following doubts, as I had many problems with env Varibles, I installed foreman gem for my development. Foreman works as my webserver and loads the ENV Variables from a env file. I have also a Procfile with the follwing code:

web: bundle exec rails s .env Procfile


The problem is that production still runs with puma and without Procfile

=> Booting Puma => Rails 5.0.1 application starting in production on http://0.0.0.0:21255 => Run `rails server -h` for more startup options [4] Puma starting in cluster mode...


Thanks a lot for your help Please give me a comment or just any tip to help me solve this

Fabrizio Bertoglio


fabrizio bertoglio

unread,
Mar 2, 2017, 3:15:37 PM3/2/17
to Ruby on Rails: Talk
Reply all
Reply to author
Forward
0 new messages