简体   繁体   English

Databasedotcom gem:根据会话ID检索用户信息

[英]Databasedotcom gem : Retrieve user info based on session id

I am using databasedotcom gem for interacting with salesforce. 我正在使用databasedotcom gem与Salesforce进行交互。 I am able to get sObject(Account,Contact,Lead) info. 我能够获取sObject(Account,Contact,Lead)信息。 Can any one tell me how to get the user info by passing salesforce session id. 谁能告诉我如何通过传递Salesforce会话ID来获取用户信息。

Below code is used to get Account detail from salesforce, but i need to retrieve User info based on session id 以下代码用于从salesforce获取帐户详细信息,但我需要根据会话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

After days of working on this, it turns out the :token parameter is the same as the Session ID. 经过几天的努力,事实证明:token参数与会话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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM