diff --git a/src/NetCoreForce.Client/AuthenticationClient.cs b/src/NetCoreForce.Client/AuthenticationClient.cs
index 93a2c51..abcc5ce 100644
--- a/src/NetCoreForce.Client/AuthenticationClient.cs
+++ b/src/NetCoreForce.Client/AuthenticationClient.cs
@@ -119,6 +119,24 @@ public Task UsernamePasswordAsync(string clientId, string clientSecret, string u
/// Thrown if the authentication fails
public async Task UsernamePasswordAsync(string clientId, string clientSecret, string username, string password, string tokenRequestEndpointUrl)
{
+ await UsernamePasswordAsync(clientId, clientSecret, username, password, tokenRequestEndpointUrl,
+ response => JsonConvert.DeserializeObject(response),
+ response => JsonConvert.DeserializeObject(response));
+ }
+
+ ///
+ /// Authenticate using the "Username and Password" auth flow
+ ///
+ /// Client ID, a.k.a. Consumer Key
+ /// Client Secret, a.k.a. Consumer Secret
+ /// Username
+ /// Password
+ /// Token request endpoint URL, e.g. https://login.salesforce.com/services/oauth2/token
+ /// Function to deserialize the access token response
+ /// Function to deserialize the auth error response
+ /// Thrown if the authentication fails
+ public async Task UsernamePasswordAsync(string clientId, string clientSecret, string username, string password, string tokenRequestEndpointUrl, Func DeserializeAccessToken, Func DeserializeAuthError)
+ {
#if DEBUG
Stopwatch sw = new Stopwatch();
sw.Start();
@@ -153,7 +171,7 @@ public async Task UsernamePasswordAsync(string clientId, string clientSecret, st
if (responseMessage.IsSuccessStatusCode)
{
- this.AccessInfo = JsonConvert.DeserializeObject(response);
+ this.AccessInfo = DeserializeAccessToken(response);
}
else if (responseMessage.StatusCode == HttpStatusCode.NotFound)
{
@@ -162,7 +180,7 @@ public async Task UsernamePasswordAsync(string clientId, string clientSecret, st
}
else
{
- var errorResponse = JsonConvert.DeserializeObject(response);
+ var errorResponse = DeserializeAuthError(response);
throw new ForceAuthException(errorResponse.Error, errorResponse.ErrorDescription, responseMessage.StatusCode);
}
#if DEBUG