Skip to content

Commit

Permalink
SDLCOM-6184: Authenticating 2024: IDX12729: Unable to decode the header
Browse files Browse the repository at this point in the history
* Remove unused code

* Increase version to 2.0.2.0
  • Loading branch information
ealbu authored Sep 12, 2024
1 parent 18f83cf commit 235d1a0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion MicrosoftTranslatorProvider/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyFileVersion("2.0.2.0")]
13 changes: 2 additions & 11 deletions MicrosoftTranslatorProvider/Service/MicrosoftService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public static async Task<bool> AuthenticateUser(MicrosoftCredentials credentials
var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
var tokenString = await response.Content.ReadAsStringAsync();
var token = ReadToken(tokenString);
credentials.AccessToken = "Bearer " + tokenString;
return true;
}
Expand All @@ -50,7 +49,7 @@ public static async Task<bool> AuthenticateUser(MicrosoftCredentials credentials
}
}

public async static Task<List<TranslationLanguage>> GetSupportedLanguages()
public static async Task<List<TranslationLanguage>> GetSupportedLanguages()
{
var httpClientHandler = ProxyHelper.GetHttpClientHandler(CredentialsManager.GetProxySettings(), true);
var httpClient = new HttpClient(httpClientHandler);
Expand All @@ -70,21 +69,13 @@ public async static Task<List<TranslationLanguage>> GetSupportedLanguages()
return output;
}

public async static Task<HashSet<string>> GetSupportedLanguageCodes()
public static async Task<HashSet<string>> GetSupportedLanguageCodes()
{
var supportedLanguages = await GetSupportedLanguages();
var supportedCodes = new HashSet<string>(supportedLanguages.Select(x => x.LanguageCode));
return supportedCodes;
}

private static JwtSecurityToken ReadToken(string token)
{
var jwtHandler = new JwtSecurityTokenHandler();
var readableToken = jwtHandler.CanReadToken(token);
return readableToken ? jwtHandler.ReadJwtToken(token)
: null;
}

public static async Task<string> TranslateAsync(PairModel pairModel, string textToTranslate, MicrosoftCredentials microsoftCredentials)
{
var sourceLanguage = pairModel.SourceLanguageCode;
Expand Down
2 changes: 1 addition & 1 deletion MicrosoftTranslatorProvider/pluginpackage.manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PluginPackage xmlns="http://www.sdl.com/Plugins/PluginPackage/1.0">
<PlugInName>Microsoft Translator Provider</PlugInName>
<Version>2.0.1.0</Version>
<Version>2.0.2.0</Version>
<Description>Microsoft Translator Provider</Description>
<Author>Trados AppStore Team</Author>
<RequiredProduct name="TradosStudio" minversion="18.0" maxversion="18.9" />
Expand Down

0 comments on commit 235d1a0

Please sign in to comment.