DeepL: authorize via header

This commit is contained in:
M66B 2022-12-12 19:45:16 +01:00
parent 9627e235a9
commit d7baa92556
1 changed files with 4 additions and 2 deletions

View File

@ -209,13 +209,14 @@ public class DeepL {
}
}
URL url = new URL(getBaseUri(key) + "translate?auth_key=" + key);
URL url = new URL(getBaseUri(key) + "translate");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setReadTimeout(DEEPL_TIMEOUT * 1000);
connection.setConnectTimeout(DEEPL_TIMEOUT * 1000);
ConnectionHelper.setUserAgent(context, connection);
connection.setRequestProperty("Authorization", "DeepL-Auth-Key " + key);
connection.setRequestProperty("Accept", "*/*");
connection.setRequestProperty("Content-Length", Integer.toString(request.length()));
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
@ -272,11 +273,12 @@ public class DeepL {
String key = prefs.getString("deepl_key", null);
// https://www.deepl.com/docs-api/other-functions/monitoring-usage/
URL url = new URL(getBaseUri(key) + "usage?auth_key=" + key);
URL url = new URL(getBaseUri(key) + "usage");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setReadTimeout(DEEPL_TIMEOUT * 1000);
connection.setConnectTimeout(DEEPL_TIMEOUT * 1000);
ConnectionHelper.setUserAgent(context, connection);
connection.setRequestProperty("Authorization", "DeepL-Auth-Key " + key);
connection.connect();
try {