Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.


  • Sé el primero en comentar

  • Sé el primero en recomendar esto


  1. 1. Omniauth GemAll, Every and Authentication Everywhere Omni + auth By Sumit Munot
  2. 2. How to Use Omniauth to Authenticate Our Users?We Needs to Sign Up For Various Applications andSites Separately.Why?We have already sign up on many, using differentusernames, that going back to one of them andtrying to remember our credentials is sometimesimpossible.
  3. 3. Now a days, most of the sites offering alternativeway to sign up,By allowing us to use other sites accounts.Like• Google Account• Twitter• GitHub• FacebookIt feels like a long and arduous task.But fear not, Omniauth is here to help.
  4. 4. Omniauth allows us to easilyintegrate more than sixty authentication providers!
  5. 5. Preparing ApplicationCreate Rails applicationrails new application_nameIn GEMFILE addgem omniauthThen,Bundle install
  6. 6. Creating a ProviderHow add a provider to Omniauth?We need to sign up as a developer onproviders site.Then just we will have to make two settings inour application regardingUsername and Password.
  7. 7. If you want to use Facebook authenticationhead over to Create app hereandclick on “Create New App”
  8. 8. Getting our App id/ API key and App Secret from settings
  9. 9. Add Provider To The App Create a new file under config/initializers called omniauth.rb.Rails.application.config.middleware.use OmniAuth::Builder doprovider :facebook, YOUR_APP_ID, YOUR_APP_SECRETend Create the Controller Session $> rails generate controller sessions new create failure
  10. 10. Set path in routes.rbget /login, :to => sessions#new, :as => :loginmatch /auth/:provider/callback, :to => sessions#creatematch /auth/failure, :to => sessions#failureIn Controller app/controllers/sessions_controller.rb just adddef Createauth_hash = request.env[omniauth.auth]render :text => auth_hash.inspectend
  11. 11. Now make sure everything is working.Point the browser tolocalhost:3000/auth/facebook/Then,we’ll be redirected to Facebook so we can authorize our app.We will Authorize it, and we will be redirected back to our appand see a hash with some information.In between will be our name, our Facebook user id, and our email, among other things.If error occurred then,
  12. 12. Change Some Setting in Facebook/apps for siteredirection Blank App Domains Change site URL
  13. 13. Thanks