Low commit activity in last 3 years
No release in over a year
OmniAuth strategy for salesforce.com.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

OmniAuth Salesforce Strategy

Strategy to authenticate with Salesforce via OAuth2 in OmniAuth.

Salesforce OAuth docs - https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_oauth_and_connected_apps.htm

Note: This is a fork of an abandoned fork of the original project.

Installation

Add to your Gemfile:

gem 'omniauth-salesforce-modern', require: 'omniauth-salesforce'

Then bundle install.

Salesforce API Setup

  1. Follow the instructions in https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_oauth_and_connected_apps.htm to create a "Connected app"

Usage

Here's an example for adding the middleware to a Rails app in config/initializers/salesforce.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :salesforce,
    Rails.application.credentials.dig(:salesforce, :key),
    Rails.application.credentials.dig(:salesforce, :secret)
end

You can now access the OmniAuth Salesforce URL: /auth/salesforce

NOTE: While developing your application, if you change the scope in the initializer you will need to restart your app server.

Configuration

You can configure several options, which you pass in to the provider method via a hash:

  • client_options: A hash of options to pass to the OAuth client

Here's an example of a possible configuration

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :salesforce,
    Rails.application.credentials.dig(:salesforce, :key),
    Rails.application.credentials.dig(:salesforce, :secret),
    client_options: {
      auth_scheme: :request_body
    }
end

License

See LICENSE