数据库中的身份验证失败

Ton*_*ang 3 salesforce databasedotcom-gem

我正在尝试采用databasedotcom gem,但无法超越身份验证.这是我做的(安装databasedotcom gem之后):

  1. rails c(或irb则需要'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'

所有凭据都在此过程中进行了复制和粘贴,因此没有错误; 证书已在此处下载:http://certifie.com/ca-bundle/ca-bundle.crt.txt

我反复尝试过Ruby 187和193以及Rails内部和外部,但总是收到此错误消息:

Databasedotcom :: SalesForceError:来自/Library/Ruby/Gems/1.8/gems/databasedotcom-1.3.0/lib/databasedotcom/client.rb:112:in"authenticate"的身份验证失败

我想知道我错过了什么?特别是,我担心在Salesforce中创建远程访问时使用的回调URL(我试过'oob','http:// localhost:3000'和'https://www.salesforce.com',但没有有所不同).

Ton*_*ang 5

事实证明这是由于databasedotcom中的一个错误.当您使用用户名和密码进行身份验证时,它会将它们放入不带编码的URL查询字符串中,并使用该URL发出请求.因此,我的用户名中的加号将被解释为空格.

解决方案:CGI :: escape()您的用户名和密码.