From d7baa92556fa0b212a1bde1eef2db2c1f0d5fa53 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 12 Dec 2022 19:45:16 +0100 Subject: [PATCH] DeepL: authorize via header --- app/src/main/java/eu/faircode/email/DeepL.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DeepL.java b/app/src/main/java/eu/faircode/email/DeepL.java index 3989fdf801..1dde6fe8b3 100644 --- a/app/src/main/java/eu/faircode/email/DeepL.java +++ b/app/src/main/java/eu/faircode/email/DeepL.java @@ -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 {