As you know Sitecore has a Salesforce Sales cloud connector module (Salesforce Sales cloud connector), using which you can create Salesforce contacts which can be managed from Sitecore user manager (Salesforce domain). There is this PDF file that describes on the installation steps.
I faced one major challenge with this. The default token request url used is "https://login.salesforce.com/services/oauth2/token". This is the production environment url and what I had was the Salesforce staging environment access. If you check the PDF file used for installation, there were no such settings to specify the staging token request url ("https://test.salesforce.com/services/oauth2/token").
I was able to find this github link "https://github.com/adamconn/sitecore-salesforce-connect" to download the source code for Salesforce connector. This might be an older version of connector code but I still wanted to try. I got this code, and noticed there is indeed a config file where I could not only enter "consumerKey", "consumerSecret", "userName", "Password", "securityToken" (all of these that I earlier entered into Sitecore fields as mentioned in the PDF file), but now also "tokenRequestUri". So in this "tokenRequestUri" I now specified the Salesforce Staging token url of "https://test.salesforce.com/services/oauth2/token".
<client provider="salesforce" type="Sitecore.Salesforce.Client.SalesforceClient, Sitecore.Salesforce.Client" singleInstance="true">
<param desc="authenticator" type="Sitecore.Salesforce.Client.Security.PasswordAuthenticator, Sitecore.Salesforce.Client">
I was now able to view and create Salesforce Sales cloud "Contacts", that I was able to verify on Salesforce cloud staging environment ("https://test.salesforce.com/"). My ultimate target was to create Salesforce Sales cloud "Leads" but did not find any such functionality in the code. So, I added my onel custom code for the same.
Please find attached the DLLs (SitecoreSalesforce, SitecoreSalesforceClient) for this latest updated Salesforce connector with my code to create Salesforce "Leads".
So, here are the steps:
1- Copy the config file "Sitecore.Salesforce.Config" into "...\App_Config\Sitecore\SalesforceConnect". Add parameters under [<client provider="salesforce"] as shown above.
2- You copy the dlls "Sitecore.Salesforce.dll" and "Sitecore.Salesforce.Client.dll" into your Sitecore solution bin folder.
3- Add reference to these dlls in your Sitecore project, you can create a form to accept the Lead parameters and then create an object of my custom class "Leads" as follows:
public bool CreateLead(string firstName, string lastName, string email, string phone, string company)
Leads salesforceLead = new Leads();
OperationResult result = salesforceLead.Create(firstName, lastName, phone, email, company);
You can verify if the Lead is created right by visiting the Salesforce Sales cloud site (in my case "https://test.salesforce.com") and the Leads section.