MicrosoftTranslator / DocumentTranslation

Command Line tool and Windows application for document translation, a local interface to the Azure Document Translation service for Windows, macOS and Linux.
Other
148 stars 34 forks source link

Unable to test successfully #110

Open Lippy1m1 opened 1 year ago

Lippy1m1 commented 1 year ago

Every time I "Test" I receive the same result. Test failed Invalid Key, or key does not match region. I have tried two different regions with the same result. What am I doing wrong here?

image

chriswendt1 commented 1 year ago

Hi Lippy, these three need to match and come from the same resource. image

The Text Translation Endpoint should also match the endpoint as listed in the Azure resource.

Also verify: Are you using the newest version of the app? Is the translation job working, only the test is failing? What are you seeing when you run a translation?

Lippy1m1 commented 1 year ago

image

So yes, I am using the three values from the translator resource. I have tried two different regions and the same thing happens with the test. I am using the latest version 0.9.3.2 and when I try to do a text translation the app bombs and closes.

Lippy1m1 commented 1 year ago

The translator resource is S1 pay as you go. My OS is Windows 11 64bit and I do have .net core 6.0.14 installed as well.

Lippy1m1 commented 1 year ago

Any ideas why I could be seeing these errors in testing and translation?

chriswendt1 commented 1 year ago

I don't have an idea at this point. Here is the code that produces the error message you are seeing when you run "Test":

       private static async Task TryCredentialsKey(string subscriptionKey, string azureRegion, string TextTransUri)
        {
            if (string.IsNullOrEmpty(TextTransUri)) TextTransUri = "https://api.cognitive.microsofttranslator.com";
            using HttpRequestMessage request = new() { Method = HttpMethod.Post, RequestUri = new Uri(TextTransUri + "/detect?api-version=3.0") };
            request.Headers.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
            if (azureRegion?.ToLowerInvariant() != "global") request.Headers.Add("Ocp-Apim-Subscription-Region", azureRegion);
            request.Content = new StringContent("[{ \"Text\": \"English\" }]", Encoding.UTF8, "application/json");
            HttpClient client = new();
            HttpResponseMessage response = await client.SendAsync(request);
            if (!response.IsSuccessStatusCode)
                throw new CredentialsException("Invalid key, or key does not match region.");
        }

It does a simple language detection. If all your credentials and URLs are correct, as you expect them to be, check if a firewall or proxy blocks your access to api.cognitive.microsofttranslator.com.

Lippy1m1 commented 1 year ago

Chris,

Thanks for this I was not on a VPN or anything which should block the ability to get to the api but I will load this up in Visual Studio and do a little troubleshooting and get back with you on the resolution.

Matt


From: Chris Wendt @.> Sent: Monday, March 6, 2023 11:49 PM To: MicrosoftTranslator/DocumentTranslation @.> Cc: Lippy1m1 @.>; Author @.> Subject: Re: [MicrosoftTranslator/DocumentTranslation] Unable to test successfully (Issue #110)

I don't have an idea at this point. Here is the code that produces the error message you are seeing when you run "Test":

   private static async Task TryCredentialsKey(string subscriptionKey, string azureRegion, string TextTransUri)
    {
        if (string.IsNullOrEmpty(TextTransUri)) TextTransUri = "https://api.cognitive.microsofttranslator.com";
        using HttpRequestMessage request = new() { Method = HttpMethod.Post, RequestUri = new Uri(TextTransUri + "/detect?api-version=3.0") };
        request.Headers.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
        if (azureRegion?.ToLowerInvariant() != "global") request.Headers.Add("Ocp-Apim-Subscription-Region", azureRegion);
        request.Content = new StringContent("[{ \"Text\": \"English\" }]", Encoding.UTF8, "application/json");
        HttpClient client = new();
        HttpResponseMessage response = await client.SendAsync(request);
        if (!response.IsSuccessStatusCode)
            throw new CredentialsException("Invalid key, or key does not match region.");
    }

It does a simple test translation. If all your credentials and URLs are correct, as you expect them to be, check if a firewall or proxy blocks your access to api.cognitive.microsofttranslator.com.

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoftTranslator%2FDocumentTranslation%2Fissues%2F110%23issuecomment-1457525948&data=05%7C01%7C%7C68c7ea9cbd084c9a7db508db1ec76603%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638137613986040714%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=j9ryX0rwH5v76HcAm5DNvLJ7tCJT4bGxzJWdmpID36Y%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKRDRH6SENIOCZ2YBY3DPLW2247HANCNFSM6AAAAAAVNQ65NQ&data=05%7C01%7C%7C68c7ea9cbd084c9a7db508db1ec76603%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638137613986040714%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=j4engRNTWf2MniCgAWXUOTUsnCmC4DlctvOgXg%2FgU3o%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>