As the title said I want to use the Ore API to implement an UpdateChecker inside my plugin, so when a new version is released users will get notified. However I am getting a 403 error when using the API, but in the documentation there’s nothing about authentication. I’m trying to call this URL
https://ore.spongepowered.org/api/v1/projects/universeguard/versions?limit=1&offset=0
which gives me a result when navigating to it via browser. However it gives me a 403 error when the plugin tries to poll that URL. This is the code I use to poll that URL
try {
StringBuilder result = new StringBuilder();
URL url = new URL(PluginSettings.UPDATE_URL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
BufferedReader reader = new BufferedReader((new InputStreamReader(connection.getInputStream())));
String line;
while ((line = reader.readLine()) != null) {
result.append(line);
}
reader.close();
JsonArray versions = JsonUtils.parse(result.toString(), JsonArray.class);
float latestVersion = versions.get(0).getAsJsonObject().get("name").getAsFloat();
if (latestVersion > Settings.REGION_VERSION) {
EventUtils.fire(new UpdateAvailableEvent(latestVersion));
} else {
LogUtils.log(Level.WARN, "YOU HAVE THE LATEST VERSION!");
}
} catch (IOException ex) {
LogUtils.exception(ex);
}
where PluginSettings.UPDATE_URL
is the API URL I’m trying to poll and Settings.REGION_VERSION
is the running plugin version. Is anything wrong with it?