2
votes

I'm trying to connect a rails application to Salesforce using the restforce gem.

The problem is similar to this question: Using Restforce gem with SalesForce API and Oauth 2.0

But I'm asking again because there was no good answer there, and I'm not using the Oauth method.

After login to salesforce and creating a new connected app, I get a "Consumer Key" and "Consumer Secret", but the restforce gem requires a few other credentials:

client = Restforce.new(username: 'foo', password: 'bar', security_token: 'security token', client_id: 'client_id', client_secret: 'client_secret', api_version: '41.0')

I assume the "Consumer Key" is equivalent to "client_id" and the "Consumer Secret" is equivalent to "client_secret", correct?

(Assuming also that "username" and "password" are my login credentials)

But where do I find the other credentials in Salesforce, i. e., the "security_token" and "api_version"?

And how do I configure these in my Rails app?

I've seen indications to put them in an .env file, but where is the .env file being loaded inside Rails? How do I configure the environment variables to be loaded?

(Rails newbie)

1

1 Answers

2
votes

Consumer Key and Consumer Secret is indeed the client_id and client_secret.

Here's a short article on how to find your security token: https://www.skyhighnetworks.com/cloud-security-blog/what-is-salesforce-security-token-and-how-do-i-find-it/

You can get a list of the api versions here: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_versions.htm

And regarding a .env file, it's up to you to either hardcode them in the code (not recommendable, but if you're just testing things out it might be) or to place them as environment variables or use the dotenv gem (https://github.com/bkeepers/dotenv) and work in a similar way.