fix: update DeepL API to header-based authentication
All checks were successful
CI / update (push) Successful in 1m30s
All checks were successful
CI / update (push) Successful in 1m30s
DeepL deprecated form-body authentication (auth_key in request body). Now using Authorization header as required by the API.
This commit is contained in:
@@ -149,7 +149,6 @@ class DeepLTranslationService {
|
||||
const preprocessedText = replaceGermanCookingTerms(text);
|
||||
|
||||
const params = new URLSearchParams({
|
||||
auth_key: this.apiKey,
|
||||
text: preprocessedText,
|
||||
target_lang: targetLang,
|
||||
...(preserveFormatting && { tag_handling: 'xml' })
|
||||
@@ -159,6 +158,7 @@ class DeepLTranslationService {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Authorization': `DeepL-Auth-Key ${this.apiKey}`,
|
||||
},
|
||||
body: params.toString()
|
||||
});
|
||||
@@ -218,7 +218,6 @@ class DeepLTranslationService {
|
||||
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
auth_key: this.apiKey,
|
||||
target_lang: targetLang,
|
||||
});
|
||||
|
||||
@@ -231,6 +230,7 @@ class DeepLTranslationService {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Authorization': `DeepL-Auth-Key ${this.apiKey}`,
|
||||
},
|
||||
body: params.toString()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user