Skip to content

Commit 1cbb3f4

Browse files
committed
feat: Use headers for tokens
1 parent 1b39d48 commit 1cbb3f4

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

compiled/payload-webhook.smx

-16.8 KB
Binary file not shown.

scripting/payload-webhook.sp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ public void OnPluginStart()
3636
PrintToServer("[Payload] Plugin loaded.");
3737
}
3838

39-
public Action testUpload(int client, int args){
39+
public Action testUpload(int client, int args)
40+
{
4041
LogUploaded(true, "2961236", "https://logs.tf/2961236");
4142
return Plugin_Handled;
4243
}
4344

4445
public int LogUploaded(bool success, const char[] logid, const char[] url)
4546
{
46-
if (success) {
47+
if (success)
48+
{
4749
bool sendRequest = GetConVarBool(g_hCvarSendLogs);
4850
if (sendRequest == false)
4951
return;
@@ -73,25 +75,32 @@ public int LogUploaded(bool success, const char[] logid, const char[] url)
7375

7476
public void SendRequest(const char[] logid, const char[] fullApiUrl)
7577
{
76-
Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST,fullApiUrl);
77-
SteamWorks_SetHTTPRequestHeaderValue(hRequest,"Content-Type","x-www-form-urlencoded");
78-
SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest, "token", g_sWebhookToken);
78+
Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST, fullApiUrl);
79+
80+
// Headers
81+
SteamWorks_SetHTTPRequestHeaderValue(hRequest, "Content-Type", "x-www-form-urlencoded");
82+
SteamWorks_SetHTTPRequestHeaderValue(hRequest, "Authorization", g_sWebhookToken);
83+
84+
// Body
7985
SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest, "logsId", logid);
80-
SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest, "requester", VERSION);
86+
8187
SteamWorks_SetHTTPCallbacks(hRequest, OnSteamWorksHTTPComplete);
8288
SteamWorks_SendHTTPRequest(hRequest);
83-
8489
}
85-
public int OnSteamWorksHTTPComplete(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, any data) {
86-
if (bFailure){
90+
91+
public int OnSteamWorksHTTPComplete(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, any data)
92+
{
93+
if (bFailure)
94+
{
8795
PrintToChatAll("[Payload] Unable to post logs preview");
8896
PrintToServer("[Payload] Unable to post logs preview");
89-
PrintToServer("Status Code: %i",eStatusCode);
97+
PrintToServer("Status Code: %i", eStatusCode);
9098
}
9199
else
92100
{
93101
PrintToChatAll("[Payload] Log preview uploaded");
94102
PrintToServer("[Payload] Log preview uploaded");
95103
}
104+
96105
delete hRequest;
97106
}

0 commit comments

Comments
 (0)