Problem with cloud based TM and the credentials

Hello,

I am creating a FileBasedProject based on a template. The template references a cloud-based TM. When I try to run the task sequence via the Studio API, I get the following error:

Unexpected exception when initializing task 'Analyze Files': Authentication failed for translation provider 'languagecloud.translation.https://671a3cbd5ba2d5774df8cd41/?SmartLookupEnabled=False&ProfileName=General%2b-%2bTranslation%2bEngine'..

I added the following code. Unfortunately, I cannot get the authentication to work. I copied the URI directly from the template file. We log in via SSO.

// Add credentials
newProject.Credentials.AddCredential(new Uri(“languagecloud.translation.https://671a3cbd5ba2d5774df8cd41/?SmartLookupEnabled=False&ProfileName=General%2b-%2bTranslation%2bEngine”), true, “user”, “password”);

Is this the right way to do it? Does a domain have to be specified for the user? If so, in what form? “domain\user” has not worked so far.

Thank for your help.



-
[edited by: André at 1:45 PM (GMT 1) on 9 May 2025]
Parents
  • Hi , please make reference to this forum post that provides information on how access a language cloud resource from Trados Studio automation:  RE: Programmatically Pre-translate a Project with Language Weaver as a MT resource 

    Example automation project: github.com/.../StandAloneConsoleApp_PretranslateUsingProvider

    Patrick Andrew Hartnett | RWS Group

  • Hi Patrick,

    thanks for the reference to the other post.

    I tried it, but I still get "Authentication failed".

    The example in the other post is kind of strange. I added the credentials (API Key) and later in the code a authentication via Client ID is done. I would expect, that API Key should be enough. Authentication via Client ID is working. The token will be returned.

    This is basically the code. Maybe I overlooked something.

            public void Create()
            {
                // Load Template
                ProjectTemplateReference template = new ProjectTemplateReference(_templateFile);
    
                // New template based project
                FileBasedProject newProject = new FileBasedProject(this.GetInfoForTemplateProject(), template);
                Console.Clear();
    
                // Add credentials
    
                // Update this variable with the actual URI of the translation provider.
                // You can retrieve this value from an existing project or project template (.sdlproj/.sdltpl).
                // To do this, open the project file in a text editor of your choice.
                // Look for the XML element <CascadeEntryProvider> and its child elements.
                // These elements should contain the URI for the translation provider.
                //
                // For example:
                // - URIs starting with "languagecloud.translation.https://" indicate a Translation Engine.
                //
                // Copy the complete URI from the project/template file and assign it to the variable below.
                //
                // Example URI: 
                // If a project template is used, you would typically need to map the URI from the project template file to the actual URI.
                // For the sake of this example, change this value with the actual tpUri string.
                // This is because, when the project automation api is used, the credentials need to be provided explicitly as it works outside the context of Trados Studio.
                var tpUriString = @"languagecloud.translation.https://671a3cbd5ba2d5774df8cd41/?"; // Paste URI here
    
                // The API key can be obtained from the Language Cloud web interface.
                // Navigate to: Users -> Integrations -> API Keys.
                // Copy the API key from this section.
                var apiKey = "<removed>"; // Paste the API Key here
    
                //if (string.IsNullOrEmpty(templatePath))
                //{
                //    var tpConfig = newProject.GetTranslationProviderConfiguration();
    
                //    var tpReference = new TranslationProviderReference(new Uri(tpUriString), null, true);
                //    var tpCascadeEntry = new TranslationProviderCascadeEntry(tpReference, true, true, false);
                //    tpConfig.Entries.Add(tpCascadeEntry);
                //    newProject.UpdateTranslationProviderConfiguration(tpConfig);
                //}
    
                newProject.Credentials.AddCredential(new Uri(tpUriString), apiKey);
                newProject.Save();
    
                //Console.WriteLine("Adding source files to the SDL project...");
                // Add files to project
                this.AddFiles(newProject, _filesWithPm);
                newProject.Save();
    
                ProjectFile[] projectFiles = newProject.GetSourceLanguageFiles();
    
                //Console.WriteLine("Adding Perfect Match files to the SDL project...");
                // Add Perfect Match files
                this.AddPerfectMatchFiles(newProject, projectFiles);
    
                //Login to LC for projects with Translation Engine providers 
                var lcService = new LcService();
                lcService.LoginToLC();
    
                // Run Tasks
                newProject.RunAutomaticTask(projectFiles.GetIds(), AutomaticTaskTemplateIds.Scan);
    
                // Process
                CreateProject(newProject, projectFiles);
    
                // Save Project
                newProject.Save();
    
                // Get amount of words that needs to be translated
                _sdlp.Words = GetProjectStatistics(newProject);
    
                // Open Project
                if (_autoOpen)
                    Process.Start(newProject.FilePath);
            }

  • Hello  

    Thanks for your detailed feedback and for flagging this issue.

    We have investigated and updated the Standalone Console Application to fix it. The problem seems to be related to a binding redirect for System.ComponentModel.Annotations, that is now required for the latest releases of Trados Studio 2024

    You can find the updated project here; make reference to the App.config file with the binding redirects

    Please test it out and let us know if you run into any more issues or have questions!

    Best Regards,

    Alexandru Florescu

  • Hello Alexandru,

    I tried it and it looks good now. The first test was a success. We will do some extented tests next week.

    Thank you so far.

    Best regards,
    Andre

Reply Children
No Data