Here is C#.NET code to generate Adobe Sign Refresh token and then update the Access token using the refresh token programmatically in C#.NET Core 8.0.
public static List<KeyValuePair<string, string>> GenerateNewRefreshToken()
{
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://<yourcompany>.na2.adobesign.com/oauth/v2/token");
var collection = new List<KeyValuePair<string, string>>();
collection.Add(new KeyValuePair<string, string>("code", code));
collection.Add(new KeyValuePair<string, string>("client_id", "<Your Adobe Client ID>"));
collection.Add(new KeyValuePair<string, string>("client_secret", "<Your Adobe Client Secret>"));
collection.Add(new KeyValuePair<string, string>("redirect_uri", "<Your Website URL>"));
collection.Add(new KeyValuePair<string, string>("grant_type", "authorization_code"));
var content = new FormUrlEncodedContent((IEnumerable<KeyValuePair<string,string>>)collection);
request.Content = content;
var response = client.Send(request);
Console.WriteLine(response.Content.ReadAsStringAsync());
return collection;
}
C#.NET code to update Adobe Access Refresh token based on the above generated refresh token.
public static List<KeyValuePair<string, string>> UpdateAccessToken(string refreshToken)
{
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://<yourcompany>.na2.adobesign.com/oauth/v2/refresh");
var collection = new List<KeyValuePair<string, string>>();
collection.Add(new("refresh_token", refreshToken));
collection.Add(new("client_id", <your client idvalue>));
collection.Add(new("client_secret", <your client secret value>));
collection.Add(new("grant_type", "refresh_token"));
var content = new FormUrlEncodedContent(collection);
request.Content = content;
var response = client.Send(request);
Console.WriteLine(response.Content.ReadAsStringAsync());
return collection;
}