mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Re-authorize if token has expired.
This commit is contained in:
parent
c60cd9dae6
commit
74fef1a240
1 changed files with 29 additions and 13 deletions
|
@ -74,6 +74,23 @@ public class ValhallaSkinServer implements SkinServer {
|
||||||
try (CloseableHttpClient client = HttpClients.createSystem()) {
|
try (CloseableHttpClient client = HttpClients.createSystem()) {
|
||||||
authorize(client, session);
|
authorize(client, session);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return upload(client, session, image, type, metadata);
|
||||||
|
} catch (IOException e) {
|
||||||
|
if (e.getMessage().equals("Authorization failed")) {
|
||||||
|
accessToken = null;
|
||||||
|
authorize(client, session);
|
||||||
|
return upload(client, session, image, type, metadata);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, HDSkinManager.skinUploadExecutor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SkinUploadResponse upload(CloseableHttpClient client, Session session, @Nullable URI image,
|
||||||
|
MinecraftProfileTexture.Type type, Map<String, String> metadata)
|
||||||
|
throws IOException {
|
||||||
GameProfile profile = session.getProfile();
|
GameProfile profile = session.getProfile();
|
||||||
|
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
|
@ -88,8 +105,7 @@ public class ValhallaSkinServer implements SkinServer {
|
||||||
default:
|
default:
|
||||||
throw new IOException("Unsupported URI scheme: " + image.getScheme());
|
throw new IOException("Unsupported URI scheme: " + image.getScheme());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, HDSkinManager.skinUploadExecutor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SkinUploadResponse resetSkin(CloseableHttpClient client, GameProfile profile, MinecraftProfileTexture.Type type) throws IOException {
|
private SkinUploadResponse resetSkin(CloseableHttpClient client, GameProfile profile, MinecraftProfileTexture.Type type) throws IOException {
|
||||||
|
|
Loading…
Reference in a new issue