DeepL: authorize via header

pull/210/head
M66B 2 years ago
parent 9627e235a9
commit d7baa92556

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

Loading…
Cancel
Save