I have C# application which running on daily bases for the last 18 months. The application access SalesForce using 3rd party DLL which I find in GitHub - https://github.com/developerforce/Force.com-Toolkit-for-NET

Yesterday I saw that the Dll failed authenticate SalesForce. The error I get is:

Message "authentication failure"

Error InvalidGrant Salesforce.Common.Models.Error

The user is valid - I manage to login with it to the browser as well no change had taken in the secret key/token

This is how I do the connection:

        consumerkey = ConfigurationManager.AppSettings["Salesforce_consumerkey"];
        consumersecret = ConfigurationManager.AppSettings["Salesforce_consumersecret"];
        username = ConfigurationManager.AppSettings["Salesforce_user"];
        password = ConfigurationManager.AppSettings["Salesforce_password"];

        AuthenticationClient auth = null;
        Task t = null;

            //create auth client to retrieve token
            auth = new AuthenticationClient();

            //get back URL and token            
            t = auth.UsernamePasswordAsync(consumerkey, consumersecret, username, password);                
        catch (Exception e)
            throw new Exception("Fail to create SF authentication", e);

No idea why now it stopped working.


Sounds like a TLS1.0 issue given the date it happened. The DLL is not able to use tls 1.1 or higher. Here is the tracked GitHub issue for the project

Workaround in issue from avesse

As far as I know, no. Our workaround is to call the following before calling AuthenticationClient methods:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

Relevant SF Information


The September 23, 2017, phase of Salesforce’s planned disablement of TLS 1.0 has been completed. If you are experiencing issues connecting between Salesforce and any integrations, browsers, or other third-party applications, please log a case with Support via the Help & Training portal. If this is a critical production issue affecting all users, please call Support to log a Severity 1 case. A subset of users attempting to login via browsers that are not compliant with TLS 1.1 or higher may not have the ability to log a case through the Help & Training portal. In this event, please call 1-800-NOSOFTWARE to log a case.

| improve this answer | |
  • Indeed that solved the case. – aralele Sep 27 '17 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.