Skip to main content
When I try to authenticate to SalesForce in order to get access to the data I get this message: "retry your request".

The authentication was successful till this morning. I know that for unsuccessful authentication you should receive different error (authentication failure).

How to overcome this issue?

This is my code:

 string securityToken = ConfigurationManager.AppSettings["SecurityToken"];

            string ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"];

            string ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"];

            string Username = ConfigurationManager.AppSettings["Username"];

            string Password = ConfigurationManager.AppSettings["Password"] + securityToken;

            string IsSandboxUser = ConfigurationManager.AppSettings["IsSandboxUser"];

            var url = IsSandboxUser.Equals("true", StringComparison.CurrentCultureIgnoreCase)

                ? "https://test.salesforce.com/services/oauth2/token"

                : "https://login.salesforce.com/services/oauth2/token";

            var auth = new AuthenticationClient(new HttpClient());

            try

            {

                await auth.UsernamePasswordAsync(ConsumerKey, ConsumerSecret, Username, Password, url);

            }

            catch (Exception ex)

            {

                throw;

            }
2 answers
  1. Jul 21, 2016, 11:48 PM
    Hi Blagoj,

    Please try adding this line of code:

                   

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

    await auth.UsernamePasswordAsync(ConsumerKey, ConsumerSecret, Username, Password, url);

    I had the same issue. It worked for me.
0/9000