You need to sign in to do that
Don't have an account?

Authenticating using AuthenticationClient.UsernamePasswordAsync() throws exception with message "retry your request"
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;
}
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;
}
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.