function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Olivier CrivelliOlivier Crivelli 

Trying to connect an .Net App using OAuth

Hi,
I'm beginner in SalesForce development. I'im trying to connect the Sample Application "SimpleConsole" to my SalesForce account, to try to understand how to connect a .NET app to SalesForce. For this:
  • I've created an application From SalesForce (name is ABITestOAuth)
  • I've got the the Consumer Key and Consumer Secret which I put in my .Net project
  • I've used my Username and password (SalesForce / Force.com devleoper account)
In my code I did the following (like in the sample)
var auth = new AuthenticationClient();
var url = IsSandboxUser.Equals("true", StringComparison.CurrentCultureIgnoreCase)
                ? "https://test.salesforce.com/services/oauth2/token"
                : "https://login.salesforce.com/services/oauth2/token";
 await auth.UsernamePasswordAsync(ConsumerKey, ConsumerSecret, Username, Password, url);

But no way to get a connection.
My question are:
Did I do something wrong until here, or did I miss some important steps?
I wanted to go back to my application in SalesForce to check the Consumer Key and Consumer Secret, but was not able to find this information again. Where can I access to this information after having created the application in SalesForce?

Any help would be welcome
Thanky in advance and best regards
Olivier
JonathanBaltzJonathanBaltz
Hey Olivier,
I'll answer your second question first:  If you log into your salesforce developer org and to the the Setup menu, the Connected Apps that have been created are found in Setup under Build > Create > Apps.  There is a section towards the botton that list the Connected Apps.  

As for connecting to the App, you may have missed one small item, but I'd like to confirm.  In the Config Manager in the .Net Application, I believe there's an entry for the ConsumerKey, ConsumerSecret, UserName and Password.  There's also an entry for SecurityToken.  In Salesforce development, it's like a two-factor authentication for applications using the APIs.  To access the SecurityToken, you would click "My Settings" in the dropdown under your name.  And on the My Settings page, click "Personal" in the list on the left, and then "Reset My Security Token."  On the following page, click the button to be sent a new Security Token.  Add this to the ConfigurationManager, and the Connection between the .Net app and your Salesforce environment should be set up. 

jonathan
Olivier CrivelliOlivier Crivelli
Thank you Jonathan, It works fine now,