Added User-Agent to Ore update checker to fix 403 error

This commit is contained in:
Risto Lahtela 2021-10-31 15:09:48 +02:00
parent ea7a214ef4
commit 967adb226a

View File

@ -76,6 +76,7 @@ public class OreVersionInfoLoader {
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", String.format("OreApi session=\"%s\"", session)); connection.setRequestProperty("Authorization", String.format("OreApi session=\"%s\"", session));
connection.setRequestProperty("User-Agent", "Player Analytics Update Checker");
connection.connect(); connection.connect();
try (InputStream in = connection.getInputStream()) { try (InputStream in = connection.getInputStream()) {
JsonArray versions = new JsonParser().parse(readInputFully(in)).getAsJsonObject().get("result").getAsJsonArray(); JsonArray versions = new JsonParser().parse(readInputFully(in)).getAsJsonObject().get("result").getAsJsonArray();
@ -94,6 +95,7 @@ public class OreVersionInfoLoader {
try { try {
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setRequestMethod("POST"); connection.setRequestMethod("POST");
connection.setRequestProperty("User-Agent", "Player Analytics Update Checker");
connection.connect(); connection.connect();
try (InputStream in = connection.getInputStream()) { try (InputStream in = connection.getInputStream()) {
return new JsonParser().parse(readInputFully(in)).getAsJsonObject().get("session").getAsString(); return new JsonParser().parse(readInputFully(in)).getAsJsonObject().get("session").getAsString();