Pregunta

I want to implement omniauth-instagram and omniauth-facebook into my Rails project and keep running into problems and also keep getting confused by all the resources that are out there.

I want to focus on this resource:
https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview

The resource above mentions:
Remember that config.omniauth adds omniauth provider middleware to your application. This means you should not add this provider middleware again in config/initializers/omniauth.rb as they'll clash with each other and result in always-failing authentication.

I want to clarify what this means in relation to the config/initializers/omniauth.rb mentioned in other documentation.

My actual question:
Should I have an omniauth.rb file or does the devise.rb configuration (as posted below) work in place of it?

devise.rb

  require "omniauth-instagram"
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE if Rails.env.development? 
  config.omniauth :instagram, 'client_id', 'secret_key'

Any points in the right direction would be great!

¿Fue útil?

Solución

I use devise+omniauth to enable users to login through facebook. The setup is in config/initializers/devise.rb. I don't have omniauth.rb.

devise.rb looks like this.(only omniauth part)

 Devise.setup do |config|

   # ==> OmniAuth
   # Add a new OmniAuth provider. Check the wiki for more information on setting
   # up on your models and hooks.
   # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'

   config.omniauth :facebook, 'APP_ID', 'APP_SECRET'

 end

Also, your devise.rb is too short. You can generate devise.rb template and using this command.

rails generate devise:install
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top