mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-04-23 02:57:31 -04:00
Handle HTTP error 429 (Too Many Requests) in the microsoft login
I will do it properly later with Retry-After tag, I promise...
This commit is contained in:
@@ -192,7 +192,7 @@ public class MicrosoftBackgroundLogin {
|
||||
}
|
||||
|
||||
/** @return [uhs, token]*/
|
||||
private String[] acquireXsts(String xblToken) throws IOException, JSONException, PresentedException {
|
||||
private String[] acquireXsts(String xblToken) throws IOException, JSONException {
|
||||
URL url = new URL(xstsAuthUrl);
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
@@ -268,7 +268,7 @@ public class MicrosoftBackgroundLogin {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void checkMcProfile(String mcAccessToken) throws IOException, JSONException, PresentedException {
|
||||
private void checkMcProfile(String mcAccessToken) throws IOException, JSONException {
|
||||
URL url = new URL(mcProfileUrl);
|
||||
|
||||
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
||||
@@ -309,7 +309,7 @@ public class MicrosoftBackgroundLogin {
|
||||
|
||||
|
||||
/** Set common properties, and enable interactivity if desired */
|
||||
private static void setCommonProperties(HttpURLConnection conn, String formData, boolean interactive){
|
||||
private static void setCommonProperties(HttpURLConnection conn, String formData, boolean interactive) {
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
conn.setRequestProperty("Accept", "application/json");
|
||||
conn.setRequestProperty("charset", "utf-8");
|
||||
@@ -341,6 +341,9 @@ public class MicrosoftBackgroundLogin {
|
||||
|
||||
private void throwResponseError(HttpURLConnection conn) throws IOException {
|
||||
Log.i("MicrosoftLogin", "Error code: " + conn.getResponseCode() + ": " + conn.getResponseMessage());
|
||||
if(conn.getResponseCode() == 429) {
|
||||
throw new PresentedException(R.string.microsoft_login_retry_later);
|
||||
}
|
||||
throw new RuntimeException(conn.getResponseMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.kdt.pojavlaunch.authenticator.microsoft;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class PresentedException extends Exception {
|
||||
public class PresentedException extends RuntimeException {
|
||||
final int localizationStringId;
|
||||
final Object[] extraArgs;
|
||||
|
||||
|
||||
@@ -348,4 +348,5 @@
|
||||
<string name="toast_turn_on_gyro">Enable gyro controls first to use this!</string>
|
||||
<string name="preference_gyro_sample_rate_title">Gyroscope sampling rate</string>
|
||||
<string name="preference_gyro_sample_rate_description">If you have performance issues with the gyroscope controls, increase this</string>
|
||||
<string name="microsoft_login_retry_later">Too many requests, please try again later.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user