public async Task Auth_InvalidLogin() { try { await _auth.UsernamePasswordAsync(_consumerKey, _consumerSecret, _username, "WRONGPASSWORD", TokenRequestEndpointUrl); } catch (ForceAuthException ex) { Assert.IsNotNull(ex); Assert.IsNotNull(ex.Message); Assert.IsNotNull(ex.Error); Assert.IsNotNull(ex.HttpStatusCode); Assert.AreEqual(ex.Message, "authentication failure"); Assert.AreEqual(ex.Error, Error.InvalidGrant); Assert.AreEqual(ex.HttpStatusCode, HttpStatusCode.BadRequest); } }
public void Init() { if (string.IsNullOrEmpty(_consumerKey) && string.IsNullOrEmpty(_consumerSecret) && string.IsNullOrEmpty(_username) && string.IsNullOrEmpty(_password) && string.IsNullOrEmpty(_organizationId)) { _consumerKey = Environment.GetEnvironmentVariable("ConsumerKey"); _consumerSecret = Environment.GetEnvironmentVariable("ConsumerSecret"); _username = Environment.GetEnvironmentVariable("Username"); _password = Environment.GetEnvironmentVariable("Password"); _organizationId = Environment.GetEnvironmentVariable("OrganizationId"); } // Use TLS 1.2 (instead of defaulting to 1.0) const int SecurityProtocolTypeTls11 = 768; const int SecurityProtocolTypeTls12 = 3072; ServicePointManager.SecurityProtocol |= (SecurityProtocolType)(SecurityProtocolTypeTls12 | SecurityProtocolTypeTls11); _auth = new AuthenticationClient(); _auth.UsernamePasswordAsync(_consumerKey, _consumerSecret, _username, _password).Wait(); _client = new ForceClient(_auth.InstanceUrl, _auth.AccessToken, _auth.ApiVersion); }