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.

Bruno Fagundez

June 11, 2015
Tweet

More Decks by Bruno Fagundez

Other Decks in Programming

Transcript

  1. 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
  2. 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