0

I am using databasedotcom gem for interacting with salesforce. I am able to get sObject(Account,Contact,Lead) info. Can any one tell me how to get the user info by passing salesforce session id.

Below code is used to get Account detail from salesforce, but i need to retrieve User info based on session id

client = Databasedotcom::Client.new("config/databasedotcom.yml")
client.authenticate :username => 'xxxxxx', :password => 'xxxxx'
client.sobject_module =SFDC_Models
client.materialize("Account")    
@acc = SFDC_Models::Account.all
Muzaffer
  • 196
  • 1
  • 5
  • 13
  • Check if you can salvage something from http://stackoverflow.com/questions/14447328/query-for-username-in-salesforce-ios-sdk. I know it's different library, platform etc but either you can run a similar REST callout or basic data (similar to `UserInfo` from Apex / SOAP API) will be returned to you during succesful login so you'd just have to dig for it in the gem's documentation. – eyescream Mar 06 '13 at 18:33
  • I will check this link and update you – Muzaffer Mar 08 '13 at 05:25

1 Answers1

0

After days of working on this, it turns out the :token parameter is the same as the Session ID. Nothing about this is documented, but hopefully it can help someone else in the future.

class HomeController < ApplicationController
        def create
                @session_id = salesforce_params[ :sid ]
                location_split = salesforce_params[ :url ].split("/")
                @location = "http://" + location_split[2]     

                client = Databasedotcom::Client.new                    
                client.authenticate :token => @session_id, :instance_url => @location
                render :text => client.list_sobjects
        end

        private def salesforce_params
                params.permit( :sid, :url )
        end
end
Nicholas Blasgen
  • 772
  • 7
  • 13