Use built in libs to create auth header and to combine final URL

This commit is contained in:
Daniel McAssey 2015-08-04 00:12:24 +01:00
parent 0de2447d6e
commit d14714ecb5

View file

@ -24,6 +24,7 @@
#endregion License Information (GPL v3)
using Newtonsoft.Json;
using ShareX.HelpersLib;
using System.Collections.Generic;
using System.Collections.Specialized;
@ -45,10 +46,7 @@ public override UploadResult UploadText(string text, string fileName)
Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("secret", text);
NameValueCollection headers = new NameValueCollection();
headers.Add("Authorization", "Basic " + System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes((API_USERNAME + ":" + API_KEY))));
result.Response = SendRequest(HttpMethod.POST, API_ENDPOINT, args, headers);
result.Response = SendRequest(HttpMethod.POST, API_ENDPOINT, args, CreateAuthenticationHeader(API_USERNAME, API_KEY));
if (!string.IsNullOrEmpty(result.Response))
{
@ -56,7 +54,7 @@ public override UploadResult UploadText(string text, string fileName)
if (jsonResponse != null)
{
result.URL = "https://onetimesecret.com/secret/" + jsonResponse.secret_key;
result.URL = URLHelpers.CombineURL("https://onetimesecret.com/secret/", jsonResponse.secret_key);
}
}
}