Closed DeDiamondPro closed 3 years ago
This is caused by Discord (or Cloudflare) trying to block automated requests. They seem to block the User-Agent sent by some Java versions, but allow some others.
You could try to set the User-Agent to a common value (e.g. a Firefox version) to avoid this problem.
URL downloadUrl = new URL("https://dl-game-sdk.discordapp.net/2.5.6/discord_game_sdk.zip");
URLConnection connection = downloadUrl.openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");
ZipInputStream zin = new ZipInputStream(connection.getInputStream());
(see https://github.com/JnCrMx/MinecraftDiscordLobbies/blob/1.16.4/src/main/java/com/github/JnCrMx/discordlobbies/DiscordLobbiesMod.java#L60 for an example)
that seems to do the trick, thanks!
Hi, I just started using this but quite quickly ran in to an issue, when I try to download the SDK from the discord servers it returns a 403, So I was wondering if I'm doing something wrong, there is a problem with the libary or there is a problem with discord.
I'm just using the example code for dowloading the SDK.