Search code examples
ruby-on-railsfacebookoauthsorcery

Facebook oauth login with custom parameters using Sorcery gem


I'm trying to pass a custom parameter to Facebook oauth url to get it back in the callback. I know it's possible but I'm using Sorcery gem and I need to set the parameter dynamically, I mean I can't define it in sorcery.rb initialization file, like it is now:

Rails.application.config.sorcery.configure do |config|
  config.facebook.callback_url = ENV['FACEBOOK_CALLBACK_URL']
 ...
end

I need to define in my controller, how can I do it with this gem?


Solution

  • I haven't found this documented but it worked, so just put in your controller:

    ::Sorcery::Controller::Config.facebook.callback_url = ENV['FACEBOOK_CALLBACK_URL'] + "param1=foo"
    

    and param1 will be send back to you after authentication :)