Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

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 Salesforce but have no idea what other information I need to be putting into rest force.

Does anyone have any experience with this gem? How do I use it to make the original request token request to SF?

1 Answer

0 votes
by (32.1k points)

You'll need to log in using OAuth 2.0 first, and then provide the tokens to the gem. I did that using Omniauth-Salesforce and after the tokens are handed I insatiate rest force.

Browse Categories

...