1- using Common . ExtProtocol ;
1+ using Common . ExtProtocol ;
22using Common . ExtProtocol . Utilities ;
33using Newtonsoft . Json ;
44using SimpleJSON ;
@@ -53,7 +53,7 @@ static ExtDeepLTranslateLegitimate()
5353 | SecurityProtocolType . Tls12 ;
5454 }
5555
56- private string _httpsServicePointTemplateUrl = "https://api.deepl.com/v2/translate?auth_key={0} " ;
56+ private string _httpsServicePointTemplateUrl = "https://api.deepl.com/v2/translate" ;
5757
5858 private HttpClient _client ;
5959 private HttpClientHandler _handler ;
@@ -73,11 +73,11 @@ public void Initialize( string config )
7373 var free = parts [ 1 ] ;
7474 if ( string . Equals ( free , "true" , StringComparison . OrdinalIgnoreCase ) )
7575 {
76- _httpsServicePointTemplateUrl = "https://api-free.deepl.com/v2/translate?auth_key={0} " ;
76+ _httpsServicePointTemplateUrl = "https://api-free.deepl.com/v2/translate" ;
7777 }
7878 else
7979 {
80- _httpsServicePointTemplateUrl = "https://api.deepl.com/v2/translate?auth_key={0} " ;
80+ _httpsServicePointTemplateUrl = "https://api.deepl.com/v2/translate" ;
8181 }
8282 }
8383
@@ -114,7 +114,6 @@ public async Task Translate( ITranslationContext context )
114114 List < UntranslatedTextInfo > untranslatedTextInfos = new List < UntranslatedTextInfo > ( ) ;
115115
116116 var parameters = new List < KeyValuePair < string , string > > ( ) ;
117- parameters . Add ( new KeyValuePair < string , string > ( "auth_key" , _apiKey ) ) ;
118117 if ( ! string . Equals ( context . SourceLanguage , "auto" , StringComparison . OrdinalIgnoreCase ) ) {
119118 parameters . Add ( new KeyValuePair < string , string > ( "source_lang" , FixLanguage ( context . SourceLanguage ) . ToUpperInvariant ( ) ) ) ;
120119 }
@@ -130,9 +129,10 @@ public async Task Translate( ITranslationContext context )
130129 var form = new FormUrlEncodedContent ( parameters ) ;
131130
132131 using var request = new HttpRequestMessage ( HttpMethod . Post , _httpsServicePointTemplateUrl ) ;
132+ request . Headers . Add ( "Authorization" , "DeepL-Auth-Key " + _apiKey ) ;
133+ request . Content = form ;
133134
134- // create request
135- using var response = await _client . PostAsync ( string . Format ( _httpsServicePointTemplateUrl , _apiKey ) , form ) ;
135+ using var response = await _client . SendAsync ( request ) ;
136136 response . ThrowIfBlocked ( ) ;
137137 response . EnsureSuccessStatusCode ( ) ;
138138
0 commit comments