Back

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

I am trying to adopt databasedotcom gem, but couldn't get beyond the authentication. Here is what I did (after installing databasedotcom gem):

  1. rails c (or irb then require 'databasedotcom')
  2. client=Databasedotcom::Client.new :client_id => 'foo', :client_secret=>'bar'
  3. client.ca_file = '/Users/tjiang/missioncontrol/tmp/ca-bundle.crt'
  4. client.verify_mode = OpenSSL::SSL::VERIFY_PEER
  5. client.authenticate :username=>'myusername', :password=>'mypassword'

All credentials are copy-and-pasted in the process so no mistake there; the certificate was downloaded here: http://certifie.com/ca-bundle/ca-bundle.crt.txt

I tried Ruby 187 and 193 as well as inside and outside Rails, repeatedly, but always got this error message:

Databasedotcom::SalesForceError: authentication failure from /Library/Ruby/Gems/1.8/gems/databasedotcom-1.3.0/lib/databasedotcom/client.rb:112:in `authenticate'

I wonder what I have missed here? Particularly, I am concerned about the Callback URL I used when creating a Remote Access in Salesforce (I tried 'oob', 'http://localhost:3000', and 'https://www.salesforce.com', but none made any difference).

1 Answer

0 votes
by (32.1k points)
edited by

This is due to a glitch in databasedotcom. When you use username and password to validate, it puts them into an URL query string WITHOUT encoding and POST a request with that URL. As a result, the plus sign in my username will be interpreted as a blank space.

Solution: CGI:: escape() both your username and password.

To learn in-depth about Salesforce, sign up for industry-based Salesforce Training!

Browse Categories

...