mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-02 21:20:28 +12:00
Use built in libs to create auth header and to combine final URL
This commit is contained in:
parent
0de2447d6e
commit
d14714ecb5
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue