aboutsummaryrefslogtreecommitdiff
path: root/launcher/net
diff options
context:
space:
mode:
authorTheKodeToad <TheKodeToad@proton.me>2023-03-01 09:54:49 +0000
committerTheKodeToad <TheKodeToad@proton.me>2023-03-01 14:24:56 +0000
commit1feb63052020db941a3c1a10d14c9a4791169c1a (patch)
tree800196711094dca2cce8d8dac9b318a06f3292cc /launcher/net
parent0eae9355e6597a9504320d79b7a4023b87531678 (diff)
downloadPrismLauncher-1feb63052020db941a3c1a10d14c9a4791169c1a.tar.gz
PrismLauncher-1feb63052020db941a3c1a10d14c9a4791169c1a.tar.bz2
PrismLauncher-1feb63052020db941a3c1a10d14c9a4791169c1a.zip
Allow custom Modrinth API token
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'launcher/net')
-rw-r--r--launcher/net/Download.cpp7
-rw-r--r--launcher/net/Upload.cpp6
2 files changed, 12 insertions, 1 deletions
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index 5982c8c9..0816e926 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -3,6 +3,7 @@
* PolyMC - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -116,7 +117,11 @@ void Download::executeTask()
if (APPLICATION->capabilities() & Application::SupportsFlame
&& request.url().host().contains("api.curseforge.com")) {
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
- };
+ } else if (request.url().host().contains("api.modrinth.com")) {
+ QString token = APPLICATION->getModrinthAPIToken();
+ if (!token.isNull())
+ request.setRawHeader("Authorization", token.toUtf8());
+ }
QNetworkReply* rep = m_network->get(request);
diff --git a/launcher/net/Upload.cpp b/launcher/net/Upload.cpp
index 79b6af8d..36d50c1e 100644
--- a/launcher/net/Upload.cpp
+++ b/launcher/net/Upload.cpp
@@ -3,6 +3,7 @@
* PolyMC - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -219,7 +220,12 @@ namespace Net {
if (APPLICATION->capabilities() & Application::SupportsFlame
&& request.url().host().contains("api.curseforge.com")) {
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
+ } else if (request.url().host().contains("api.modrinth.com")) {
+ QString token = APPLICATION->getModrinthAPIToken();
+ if (!token.isNull())
+ request.setRawHeader("Authorization", token.toUtf8());
}
+
//TODO other types of post requests ?
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QNetworkReply* rep = m_network->post(request, m_post_data);