Fixed Auth for OpenShock
This commit is contained in:
parent
0303efac16
commit
66f234e19a
@ -1,4 +1,5 @@
|
|||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace OpenCS2hock;
|
namespace OpenCS2hock;
|
||||||
|
|
||||||
@ -11,17 +12,18 @@ public class OpenShock : Shocker
|
|||||||
Headers =
|
Headers =
|
||||||
{
|
{
|
||||||
UserAgent = { new ProductInfoHeaderValue("OpenCS2hock", "1") },
|
UserAgent = { new ProductInfoHeaderValue("OpenCS2hock", "1") },
|
||||||
Accept = { new MediaTypeWithQualityHeaderValue("application/json") },
|
Accept = { new MediaTypeWithQualityHeaderValue("application/json") }
|
||||||
Authorization = new AuthenticationHeaderValue("Basic", ApiKey)
|
|
||||||
},
|
},
|
||||||
Content = new StringContent(@"[ { "+
|
Content = new StringContent(@"[ { "+
|
||||||
$"\"id\": \"{shockerId}\"," +
|
$"\"id\": \"{shockerId}\"," +
|
||||||
$"\"type\": {ControlActionToByte(action)},"+
|
$"\"type\": {ControlActionToByte(action)},"+
|
||||||
$"\"intensity\": {intensity},"+
|
$"\"intensity\": {intensity},"+
|
||||||
$"\"duration\": {duration}"+
|
$"\"duration\": {duration}"+
|
||||||
"}]")
|
"}]", Encoding.UTF8, new MediaTypeHeaderValue("application/json"))
|
||||||
};
|
};
|
||||||
this.HttpClient.Send(request);
|
request.Headers.Add("OpenShockToken", ApiKey);
|
||||||
|
HttpResponseMessage response = this.HttpClient.Send(request);
|
||||||
|
Console.WriteLine(response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte ControlActionToByte(ControlAction action)
|
private byte ControlActionToByte(ControlAction action)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user