SlideShare uma empresa Scribd logo
1 de 13
Omniauth Gem




All, Every and                  Authentication
 Everywhere




                 Omni + auth        By
                                    Sumit Munot
How to Use Omniauth to Authenticate Our
                Users?

We Needs to Sign Up For Various Applications and
Sites Separately.

Why?
We have already sign up on many, using different
usernames, that going back to one of them and
trying to remember our credentials is sometimes
impossible.
Now a days, most of the sites offering alternative
way to sign up,

By allowing us to use other sites accounts.
Like
• Google Account
• Twitter
• GitHub
• Facebook

It feels like a long and arduous task.

But fear not, Omniauth is here to help.
Omniauth allows us to easily
integrate more than sixty
 authentication providers!
Preparing Application

Create Rails application
rails new application_name

In GEMFILE add
gem 'omniauth'

Then,
Bundle install
Creating a Provider
How add a provider to Omniauth?

We need to sign up as a developer on
providers site.

Then just we will have to make two settings in
our application regarding
Username and Password.
If you want to use Facebook authentication
head over to
                                             Create new
developers.facebook.com/apps                  app here
and
click on “Create New App”
Getting our App id/ API key and App Secret from settings
Add Provider To The App
      Create a new file under config/initializers called
      omniauth.rb.

Rails.application.config.middleware.use OmniAuth::Builder do

provider :facebook, YOUR_APP_ID, YOUR_APP_SECRET

end


       Create the Controller Session

              $> rails generate controller sessions new create failure
Set path in routes.rb
get '/login', :to => 'sessions#new', :as => :login

match '/auth/:provider/callback', :to => 'sessions#create'

match '/auth/failure', :to => 'sessions#failure'




In Controller app/controllers/sessions_controller.rb just add
def Create

auth_hash = request.env['omniauth.auth']

render :text => auth_hash.inspect

end
Now make sure everything is working.

Point the browser to

localhost: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 app

and 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,
Change Some Setting in Facebook/apps for site
redirection


                                                      Blank App
                                                      Domains




                                        Change site
                                           URL
Thanks

Mais conteúdo relacionado

Mais procurados

App builder svco-productdeck-basilarackal
App builder svco-productdeck-basilarackalApp builder svco-productdeck-basilarackal
App builder svco-productdeck-basilarackal
Nihal Ismail
 
DevelopmentIntegrationGuides-Warbler
DevelopmentIntegrationGuides-WarblerDevelopmentIntegrationGuides-Warbler
DevelopmentIntegrationGuides-Warbler
Mark Dunlap
 

Mais procurados (19)

App builder svco-productdeck-basilarackal
App builder svco-productdeck-basilarackalApp builder svco-productdeck-basilarackal
App builder svco-productdeck-basilarackal
 
Salesforce Marketing Cloud connector for Wordpress WooCommerce
Salesforce Marketing Cloud connector for Wordpress WooCommerceSalesforce Marketing Cloud connector for Wordpress WooCommerce
Salesforce Marketing Cloud connector for Wordpress WooCommerce
 
How to integrate a subscription form with WordPress using a free plugin?
How to integrate a subscription form with WordPress using a free plugin?How to integrate a subscription form with WordPress using a free plugin?
How to integrate a subscription form with WordPress using a free plugin?
 
How to Build Your Own Social Network with Elgg?
How to Build Your Own Social Network with Elgg?How to Build Your Own Social Network with Elgg?
How to Build Your Own Social Network with Elgg?
 
Directory submission
Directory submissionDirectory submission
Directory submission
 
Final Presentation
Final PresentationFinal Presentation
Final Presentation
 
Urello wcabq
Urello wcabqUrello wcabq
Urello wcabq
 
Mobile Website Tutorial
Mobile Website TutorialMobile Website Tutorial
Mobile Website Tutorial
 
Designing REST API
Designing REST APIDesigning REST API
Designing REST API
 
Mule roles
Mule rolesMule roles
Mule roles
 
Forms authentication in asp dot net
Forms authentication in asp dot netForms authentication in asp dot net
Forms authentication in asp dot net
 
Creating an app on Ribily Part 3 flow creation
Creating an app on Ribily Part 3 flow creationCreating an app on Ribily Part 3 flow creation
Creating an app on Ribily Part 3 flow creation
 
Beyond the Theme - Using WordPress as an API
Beyond the Theme - Using WordPress as an APIBeyond the Theme - Using WordPress as an API
Beyond the Theme - Using WordPress as an API
 
DevelopmentIntegrationGuides-Warbler
DevelopmentIntegrationGuides-WarblerDevelopmentIntegrationGuides-Warbler
DevelopmentIntegrationGuides-Warbler
 
Descriptomatic review
Descriptomatic reviewDescriptomatic review
Descriptomatic review
 
O365con14 - a developer jam with yammer
O365con14 - a developer jam with yammerO365con14 - a developer jam with yammer
O365con14 - a developer jam with yammer
 
Joomla Amazon Affiliate
Joomla Amazon AffiliateJoomla Amazon Affiliate
Joomla Amazon Affiliate
 
Let's do SPA
Let's do SPALet's do SPA
Let's do SPA
 
JoomlaEXPO: Search Engine Friendly URLs - Azrul.com
JoomlaEXPO: Search Engine Friendly URLs - Azrul.comJoomlaEXPO: Search Engine Friendly URLs - Azrul.com
JoomlaEXPO: Search Engine Friendly URLs - Azrul.com
 

Destaque

Destaque (9)

Devise and Rails
Devise and RailsDevise and Rails
Devise and Rails
 
OmniAuth: From the Ground Up (RailsConf 2011)
OmniAuth: From the Ground Up (RailsConf 2011)OmniAuth: From the Ground Up (RailsConf 2011)
OmniAuth: From the Ground Up (RailsConf 2011)
 
Rails course day 6
Rails course day 6Rails course day 6
Rails course day 6
 
Building a Rails API with the JSON API Spec
Building a Rails API with the JSON API SpecBuilding a Rails API with the JSON API Spec
Building a Rails API with the JSON API Spec
 
herokuでfacebookアプリを作ったお話
herokuでfacebookアプリを作ったお話herokuでfacebookアプリを作ったお話
herokuでfacebookアプリを作ったお話
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Semelhante a Omniauth

OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
h_marvin
 
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the CloudSharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
Danny Jessee
 
Dreamwares_SF Expertise
Dreamwares_SF ExpertiseDreamwares_SF Expertise
Dreamwares_SF Expertise
Manidipa Mitra
 

Semelhante a Omniauth (20)

OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
 
Creating a content managed facebook app
Creating a content managed facebook appCreating a content managed facebook app
Creating a content managed facebook app
 
Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0 - Part 1Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0 - Part 1
 
Introduction to OAuth 2.0 - Part 1
Introduction to OAuth 2.0  - Part 1Introduction to OAuth 2.0  - Part 1
Introduction to OAuth 2.0 - Part 1
 
Facebook SSO.docx
Facebook SSO.docxFacebook SSO.docx
Facebook SSO.docx
 
How to create Zoom Meet with Pega
How to create Zoom Meet with PegaHow to create Zoom Meet with Pega
How to create Zoom Meet with Pega
 
Facebook Coin
Facebook CoinFacebook Coin
Facebook Coin
 
Passport js authentication in nodejs how to implement facebook login feature ...
Passport js authentication in nodejs how to implement facebook login feature ...Passport js authentication in nodejs how to implement facebook login feature ...
Passport js authentication in nodejs how to implement facebook login feature ...
 
Integrate facebook using mule esb
Integrate facebook using mule esbIntegrate facebook using mule esb
Integrate facebook using mule esb
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 
Intro To Bebo Applications by Thought Labs
Intro To Bebo Applications by Thought LabsIntro To Bebo Applications by Thought Labs
Intro To Bebo Applications by Thought Labs
 
Dreamwares_Salesforce Updated
Dreamwares_Salesforce UpdatedDreamwares_Salesforce Updated
Dreamwares_Salesforce Updated
 
Progressive Web Apps - Overview & Getting Started
Progressive Web Apps - Overview & Getting StartedProgressive Web Apps - Overview & Getting Started
Progressive Web Apps - Overview & Getting Started
 
Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
 
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the CloudSharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
 
Facebook + Ruby
Facebook + RubyFacebook + Ruby
Facebook + Ruby
 
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010,Claims-Based Identity, Facebook, and the CloudSharePoint 2010,Claims-Based Identity, Facebook, and the Cloud
SharePoint 2010, Claims-Based Identity, Facebook, and the Cloud
 
Login Register with Social Account using PHP
Login Register with Social Account using PHPLogin Register with Social Account using PHP
Login Register with Social Account using PHP
 
Dreamwares_SF Expertise
Dreamwares_SF ExpertiseDreamwares_SF Expertise
Dreamwares_SF Expertise
 
Mule with facebook
Mule with facebookMule with facebook
Mule with facebook
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Omniauth

  • 1. Omniauth Gem All, Every and Authentication Everywhere Omni + auth By Sumit Munot
  • 2. How to Use Omniauth to Authenticate Our Users? We Needs to Sign Up For Various Applications and Sites Separately. Why? We have already sign up on many, using different usernames, that going back to one of them and trying to remember our credentials is sometimes impossible.
  • 3. Now a days, most of the sites offering alternative way to sign up, By allowing us to use other sites accounts. Like • Google Account • Twitter • GitHub • Facebook It feels like a long and arduous task. But fear not, Omniauth is here to help.
  • 4. Omniauth allows us to easily integrate more than sixty authentication providers!
  • 5. Preparing Application Create Rails application rails new application_name In GEMFILE add gem 'omniauth' Then, Bundle install
  • 6. Creating a Provider How add a provider to Omniauth? We need to sign up as a developer on providers site. Then just we will have to make two settings in our application regarding Username and Password.
  • 7. If you want to use Facebook authentication head over to Create new developers.facebook.com/apps app here and click on “Create New App”
  • 8. Getting our App id/ API key and App Secret from settings
  • 9. Add Provider To The App Create a new file under config/initializers called omniauth.rb. Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, YOUR_APP_ID, YOUR_APP_SECRET end Create the Controller Session $> rails generate controller sessions new create failure
  • 10. Set path in routes.rb get '/login', :to => 'sessions#new', :as => :login match '/auth/:provider/callback', :to => 'sessions#create' match '/auth/failure', :to => 'sessions#failure' In Controller app/controllers/sessions_controller.rb just add def Create auth_hash = request.env['omniauth.auth'] render :text => auth_hash.inspect end
  • 11. Now make sure everything is working. Point the browser to localhost: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 app and 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. Change Some Setting in Facebook/apps for site redirection Blank App Domains Change site URL