Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RoR talking to Salesforce using OAuth

RoR talking to Salesforce using OAuth

How to connect your RoR app to Salesforce using restforce and omniauth-salesforce gems.

4608509404503ddc6b712512a6e8a471?s=128

Bruno Fagundez

June 11, 2015
Tweet

Transcript

  1. www.geekymartian.com @geekymartian RoR talking to Salesforce using OAuth +

  2. www.geekymartian.com @geekymartian Ruby

  3. www.geekymartian.com @geekymartian Ruby Gems

  4. www.geekymartian.com @geekymartian Ruby on Rails

  5. www.geekymartian.com @geekymartian =

  6. www.geekymartian.com @geekymartian OAuth

  7. www.geekymartian.com @geekymartian OAuth dance

  8. www.geekymartian.com @geekymartian

  9. www.geekymartian.com @geekymartian Connected App

  10. www.geekymartian.com @geekymartian Needed Gems restforce omniauth-salesforce

  11. www.geekymartian.com @geekymartian Rails User Model class User < ActiveRecord::Base def

    self.from_omniauth(auth) where(auth.slice(:provider, :uid).permit!).first_or_initialize.tap do |user| user.provider = auth.provider user.uid = auth.uid user.name = auth.info.name user.oauth_token = auth.credentials.token user.refresh_token = auth.credentials.refresh_token user.instance_url = auth.credentials.instance_url user.save! end end end
  12. www.geekymartian.com @geekymartian client = Restforce.new :oauth_token => current_user.oauth_token, :refresh_token =>

    current_user.refresh_token, :instance_url => current_user.instance_url, :client_id => 'YOUR-CONSUMER-KEY', :client_secret => 'YOUR-CONSUMER-SECRET' Restforce Interaction
  13. www.geekymartian.com @geekymartian http://www.geekymartian.com/articles/ruby-on-rails-4- salesforce-oauth-implementation/

  14. www.geekymartian.com @geekymartian Gracias!