Search code examples
ruby-on-railssalesforcedatabasedotcom-gem

salesforce sandbox integration in rails, error expired access


I am using the Ruby Gem "databascdotcom" to integrate Salesforce in a Rails app and all works fine until i try it with sandbox account type "Configuration Only".

The following code work fine when i used with salesforce product account. Here is my code

def SalesForceFeed
   @oppID = params[:oppid]

    client = Databasedotcom::Client.new client.client_id #=> foo client.client_secret #=> bar
    client.authenticate :username => "[email protected]", :password => "ThePasswordTheSecurityToken" #=> "the-oauth-token"
    client.materialize("Opportunity")
    begin
         @client=SalesForce::Connection.new.client
         @opp = Opportunity.find_by_Id(@oppID)
    rescue Exception=>e
end 

But when i try to use it with salesforce sandbox account with username like "[email protected]" I m getting following error "expired access/refresh token"

Any ideas?


Solution

  • Got the issue.

    Just need to add

    host= "test.salesforce.com"

    Thanks All