mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 22:21:23 +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)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using ShareX.HelpersLib;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
|
||||||
|
@ -45,10 +46,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
args.Add("secret", text);
|
args.Add("secret", text);
|
||||||
|
|
||||||
NameValueCollection headers = new NameValueCollection();
|
result.Response = SendRequest(HttpMethod.POST, API_ENDPOINT, args, CreateAuthenticationHeader(API_USERNAME, API_KEY));
|
||||||
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);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.Response))
|
if (!string.IsNullOrEmpty(result.Response))
|
||||||
{
|
{
|
||||||
|
@ -56,7 +54,7 @@ public override UploadResult UploadText(string text, string fileName)
|
||||||
|
|
||||||
if (jsonResponse != null)
|
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