function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KunjanKunjan 

How to use OAuth in Ruby to access salesforce data

Hello,

 

I want to display Contact/Account records in Ruby app. using OAuth.

Can anybody tell me how to use OAuth in Ruby to access salesforce data?

 

Your help will be highly appreciated.

 

Waiting for early response.

 

Thanks in advance,

KunjanKunjan

Hi,

 

I tried with the link which you provided. But I can't run https request from my ruby application. I am using netbeans editor and please let me know what settings needs to be done to run https request on my local system?

 

Please let me know what should I have to pass in callback url while creating remote site in salesforce as I have not valid application which run under https.

 

Can I pass  https://localhost/oauth/callback while creating Remote Site in salesforce? And what should I have to write in callback page/controller?

 

Please provide me your valuable pointer for the above queries.

Thanks,

 

cloudcodercloudcoder

FYI I just implemented a forcedotcom strategy for omniauth which will makes oauth MUCH easier. I'm writing it up over the next few days. Check back on blog.sforce.com to see when it is posted.

naveenkumarbvnaveenkumarbv

Hello Quinton,

 

     I have tried running the sample application you've developed using OmniAuth and HttParty from the following URL:

https://github.com/quintonwall/omniauth-rails3-forcedotcom/wiki/Build-Mobile-Apps-in-the-Cloud-with-Omniauth,-Httparty-and-Force.com

 

It WORKED in one of my machine but gives the following OpenSSL when I try in another one.

OpenSSL::SSL::SSLError
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

I have checked for the version of OpenSSL in both the machines and it is the same version -- OpenSSL 0.9.8o 01 Jun 2010.

What could be the reason for this?

 

Also, I have some queries regarding the implementation you have provided:

1. Is it just a sample implementation to prove that integration with salesforce from a rails 3 application is possible. I wanted to know how far can it be extended?

2. If we enable OpenSSL in WEBrick, the entire application becomes secure and has to be accessed using https protocol.

Eg: https://localhost:3000. Can we configure OpenSSL in such a way that only the calls to salesforce uses https protocol.

3. Are all the entities in salesforce available as model objects in our rails app?

4. How to handle objects with custom columns, Custom Entities in salesforce?

5. Is it possible to integrate ExactTarget, StrikeIron, etc if we are following this approach?

 

Regards,

Naveen Kumar B.V

naveenkumarbvnaveenkumarbv

 

Cant we include the username and password of salesforce in my application to authenticate, so that the user need not enter the credentials each time we interact with salesforce to perform CRUD operations, basically I need to handle all this in application level.

 

How can we modify the current implementation of forcedotcom strategy to achieve the above functionality?

cloudcodercloudcoder

That doesn't really make any sense. The whole point of OAuth is to avoid the embedding of user credentials, although you could implement the user-pass flow which Salesforce supports. The Omniauth strategy I wrote is open source and available on github if you want to create an alternate flow.

 

 

cloudcodercloudcoder

Hi Naveen,

 

I suspect your first error has to do with how you created your self-signed cert. Perhaps you tied it to your first machine and thus are unable to 'port' it onto another.

 

As for your other questions, here goes:

 

1. Yes, the sample app is a Rails3 implementation

2. Yes, you can configure webrick and any other web server to support both http and https traffic. Go a quick Google search and you should find some results on how to do it. It's not too tricky.

3. If you are using the Force.com for Ruby toolkit, all the objects as of v21 of the API are available as models in your rails app. WIth Rails3 and the release of the REST API, by default you retrieve json representations back. At the moment there are no concrete model implementations - theory being is that a)json is generally accepted as the data exchange format of choice, b)creating concrete model classes is a decent amount of work as maintenance, but the project is open source, so community contribution is appreciated :)

4. See the getting started with Ruby doc on developer.force.com

5. Yes, you would be integrating from Ruby, and would use web services/ REST etc as normal

 

naveenkumarbvnaveenkumarbv

Hello Quinton,

 

Thanks for your response. Basically our requirement is that we are not exposing salesforce directly to our customers. Our web application interacts with salesforce from back-end. So we would be interacting with salesforce with application level credentials and use this across lifetime of application. We would like to know if any sample or pointers so as to implement user-password based authentication. Thanks once again for your help.

 

Naveen