Skip to content
Richard Vanhook edited this page Dec 13, 2011 · 7 revisions

Quick Start

The omniauth-salesforce gem simplifies Single Sign-On integration between salesforce.com and ruby web apps via the OAuth 2.0 protocol. This article will quickly show you how to create a Ruby web app which leverages the gem and also how to deploy it to Heroku.

Prerequisites

Simply complete the Prerequisites listed in the Heroku "Getting Started with Ruby on Heroku/Bamboo" article.

Create a salesforce.com account

  1. Fill in required fields and submit

  2. Click on link in the confirmation email you receive

  3. Set a new password and submit

  4. Go to App Setup | Develop | Remote Access | New

  5. Fill in the following required fields with dummy values (later we'll update with real values)

    Application: My Example omniauth-salesforce app (local)

    Callback: http://localhost:5000/auth/salesforce/callback

    Contact Email: enter your email

  6. Note the Consumer Secret and Key in the Authentication section. (CONSUMERSECRET and CONSUMERKEY)

Create your web app

  • Create a new directory to store your web app
$ mkdir integrated-with-sfdc
$ cd integrated-with-sfdc
  • Create a file named Gemfile (no extension) with following contents
source :rubygems
gem "sinatra"
gem "rack-ssl"
gem "haml"
gem "omniauth"
gem "omniauth-salesforce", ">=1.0.3"
gem "thin"
  • If you're using RVM, execute the following to create a new gemset. If you're not using RVM, ignore.
$ rvm gemset create integrated-with-sfdc
'integrated-with-sfdc' gemset created
$ rvm gemset use integrated-with-sfdc
$ gem list

*** LOCAL GEMS ***

rake (0.8.7)
  • Install the bundler gem
$ gem install bundler
Fetching: bundler-1.0.21.gem (100%)
Successfully installed bundler-1.0.21
1 gem installed
Installing ri documentation for bundler-1.0.21...
Installing RDoc documentation for bundler-1.0.21...
  • And then use use bundle to install gems listed in Gemfile.
$ bundle install
Fetching source index for http://rubygems.org/
Installing addressable (2.2.6) 
Installing daemons (1.1.4) 
Installing eventmachine (0.12.10) with native extensions 
Installing multipart-post (1.1.4) 
Installing rack (1.3.5) 
Installing faraday (0.7.5) 
Installing haml (3.1.4) 
Installing hashie (1.2.0) 
Installing multi_json (1.0.4) 
Installing oauth2 (0.5.1) 
Installing omniauth (1.0.1) 
Installing omniauth-oauth2 (1.0.0) 
Installing omniauth-salesforce (1.0.3) 
Installing rack-protection (1.1.4) 
Installing rack-ssl (1.3.2) 
Installing tilt (1.3.3) 
Installing sinatra (1.3.1) 
Installing thin (1.3.1) with native extensions 
Using bundler (1.0.21) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
  • Next, create a file named web.rb with following contents
require 'sinatra'
  
get '/' do
  "Hello World"
end
  • Start app server
$ ruby -rubygems web.rb -p 5000
== Sinatra/1.3.1 has taken the stage on 5000 for development with backup from Thin
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:5000, CTRL+C to stop

Hello Open a web browser and go to http://localhost:5000

Clone this wiki locally