SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

En vedette (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?
 

Similaire à 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
 

Similaire à 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
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

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