OmniAuth Strategy for salesforce.com.
Note: This is a fork of the original project and is now the main repository for the omniauth-salesforce gem.
http://omniauth-salesforce-example.herokuapp.com
require "sinatra"
require "omniauth"
require "omniauth-salesforce"
class MyApplication < Sinatra::Base
use Rack::Session
use OmniAuth::Builder do
provider :salesforce, ENV['SALESFORCE_KEY'], ENV['SALESFORCE_SECRET']
end
end
Create config/initializers/omniauth.rb
with following content:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :salesforce, ENV['SALESFORCE_KEY'], ENV['SALESFORCE_SECRET']
end
display
- Tailors the login page to the user's device type. Currently the only values supported are:page
- Full-page authorization screen (default).popup
- Compact dialog optimized for modern web browser popup windows.touch
- mobile-optimized dialog designed for modern smartphones, such as Android and iPhone.mobile
- mobile optimized dialog designed for less capable smartphones such as BlackBerry OS 5. By default it set intotouch
orpage
depending on device.
scope
- A space separated list of scope values. The scope parameter allows you to fine-tune the permissions associated with the tokens you are requesting, selecting a subset of the values you specified when defining the connected app.state
- Any value that you wish to be sent with the callback.immediate
- Avoid interacting with the user.false
- Prompt the user for login and approval (default).true
- If the user is currently logged in and has previously approved the client_id, the approval step is skipped, and the browser is immediately redirected to the callback with an authorization code. If the user is not logged in or has not previously approved the client, the flow immediately terminates with theimmediate_unsuccessful
error code.
prompt
- Specifies how the authorization server prompts the user for reauthentication and reapproval. This parameter is optional. The only values Salesforce supports are:login
— The authorization server must prompt the user for reauthentication, forcing the user to log in again.consent
— The authorization server must prompt the user for reapproval before returning information to the client. It is valid to pass both values, separated by a space, to require the user to both log in and reauthorize. For example:?prompt=login%20consent
login_hint
- Provide a valid username value with this parameter to pre-populate the login page with the username. For example:[email protected]
. If a user already has an active session in the browser, then the login_hint parameter does nothing; the active user session continues
use OmniAuth::Builder do
provider :salesforce,
ENV['SALESFORCE_KEY'],
ENV['SALESFORCE_SECRET']
provider :salesforce_sandbox,
ENV['SALESFORCE_SANDBOX_KEY'],
ENV['SALESFORCE_SANDBOX_SECRET']
provider :database_com,
ENV['SALESFORCE_PRERELEASE_KEY'],
ENV['SALESFORCE_PRERELEASE_SECRET']
provider :salesforce_prerelease,
ENV['DATABASE_DOT_COM_KEY'],
ENV['DATABASE_DOT_COM_SECRET']
end