Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/CommonLibrariesForNET/AuthenticationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class AuthenticationClient : IAuthenticationClient, IDisposable
public string RefreshToken { get; set; }
public string Id { get; set; }
public string ApiVersion { get; set; }
public string Signature { get; set; }
public string IssuedAt { get; set; }

private const string UserAgent = "forcedotcom-toolkit-dotnet";
private const string TokenRequestEndpointUrl = "https://login.salesforce.com/services/oauth2/token";
Expand Down Expand Up @@ -78,6 +80,8 @@ public async Task UsernamePasswordAsync(string clientId, string clientSecret, st
AccessToken = authToken.AccessToken;
InstanceUrl = authToken.InstanceUrl;
Id = authToken.Id;
Signature = authToken.Signature;
IssuedAt = authToken.IssuedAt;
}
else
{
Expand Down Expand Up @@ -130,6 +134,8 @@ public async Task WebServerAsync(string clientId, string clientSecret, string re
InstanceUrl = authToken.InstanceUrl;
Id = authToken.Id;
RefreshToken = authToken.RefreshToken;
Signature = authToken.Signature;
IssuedAt = authToken.IssuedAt;
}
else
{
Expand Down Expand Up @@ -178,6 +184,8 @@ public async Task TokenRefreshAsync(string clientId, string refreshToken, string
RefreshToken = refreshToken;
InstanceUrl = authToken.InstanceUrl;
Id = authToken.Id;
Signature = authToken.Signature;
IssuedAt = authToken.IssuedAt;
}
else
{
Expand All @@ -186,6 +194,25 @@ public async Task TokenRefreshAsync(string clientId, string refreshToken, string
}
}

public async Task TokenRevokeAsync()
{
HttpRequestMessage request = new HttpRequestMessage();
request.Method = HttpMethod.Post;
request.RequestUri = new Uri("https://login.salesforce.com/services/oauth2/revoke");
request.Content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("token", AccessToken)
});

try
{
HttpResponseMessage responseMessage = await _httpClient.SendAsync(request);
}
catch (Exception ex)
{
throw new ForceAuthException(Error.UnknownException, ex.Message);
}
}

public async Task GetLatestVersionAsync()
{
Expand Down