I'm trying to use Restforce (https://github.com/ejholmes/restforce) to set up integration with my Rails app to SalesForce's API using Oauth 2.0.
Restforce describes the initialization process as follows:
Initialization
Which authentication method you use really depends on your use case. If you're building an application where many users from different orgs are authenticated through oauth and you need to interact with data in their org on their behalf, you should use the OAuth token authentication method.
If you're using the gem to interact with a single org (maybe you're building some salesforce integration internally?) then you should use the username/password authentication method.
OAuth token authentication
client = Restforce.new :oauth_token => 'oauth token', :instance_url => 'instance url'
Although the above will work, you'll probably want to take advantage of the (re)authentication middleware by specifying a refresh token, client id and client secret:
client = Restforce.new :oauth_token => 'oauth token', :refresh_token => 'refresh token', :instance_url => 'instance url', :client_id => 'client_id', :client_secret => 'client_secret'
I have my client_id
and client_secret
from the app that was created in SF, but have no idea what other information I need to be putting into restforce.
Does anyone have any experience with this gem? How do I use it to make the original request token request to SF?
You need to login using Oauth 2.0 first, then provide the tokens to the gem. I did that using Omniauth-Salesforce and after the tokens are handed I instatiate restforce.
The examples in omniauth are using sinatra, please look into this repo for an implementation using rails.
I've blogged about this as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With