I am developing a Rails app using OmniAuth, OmniAuth-salesforce and this gem: https://github.com/heroku/databasedotcom
I am hardcoding the "client_id" and "client_secret" into my app. Then for each user that authenticates with Saleforce, I am capturing their oauth token, user id, and instance url. With all this, I am creating leads on their behalf.
Everything works if the user is from the same account where I got the "client_id" and "client_secret". However, if I authenticate with a user from another Salesforce instance, I get an "invalid cross reference id" error.
I want my app to be submitting leads for users from many different Salesforce intances. Is this not possible?
Here is my full code:
client = Databasedotcom::Client.new :client_id => SALESFORCE_CLIENT_ID, :client_secret => SALESFORCE_CLIENT_SECRET
client.authenticate :token => user.salesforce_token, :instance_url => user.salesforce_instance_url
client.materialize("Lead")
lead = Lead.new(:FirstName => first_name, :LastName => last_name, :Email => email,
:Phone => phone, :OwnerId => user.salesforce_id, :IsConverted => false,
:IsUnreadByOwner => true, :Company => contact_company)
lead.save
Thanks for any advice!