none
Translator API authorization problems

    Question

  • I'm sure that I used right primary account key because I copied it from https://datamarket.azure.com/dataset/explore/bing/microsofttranslator, but I always get Exception-ACS50012: Authentication failed. Trace ID: 08568a01-6cba-4817-bece-5211964dbb36 Correlation ID: b8a46de0-9709-424a-b2ed-1bd816e56f12 Timestamp: 2014-02-03 21:21:58Z

    Why might that happened?

    Best regards.


    • Edited by Ivanovvvv48 Monday, February 03, 2014 9:39 PM
    Monday, February 03, 2014 9:38 PM

Answers

All replies

  • hello,

    Thanks for posting!

    In latest version, we must use primary key. But I am not sure you use it rightly. If you use c#, I suggest you could use below code to try again.

    private static TranslatorContainer context;
           
            public static TranslatorContainer createConnection(String USER_ID, String KEY)
            {
                USER_ID = "***";
                KEY = "**";
                context = new TranslatorContainer (new Uri("https://api.datamarket.azure.com/Bing/MicrosoftTranslator/v1/Translate"));
                context.IgnoreMissingProperties = true;
                context.Credentials = new NetworkCredential(USER_ID, KEY);
                return context;
    
            }

    About TranslatorContainer file, you could download form this page (https://datamarket.azure.com/dataset/bing/microsofttranslator ).

    Please try it.

    Regards,

    Will

     

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, February 04, 2014 7:09 AM
  • Thank you for the answer, but I'm sure to use it the right way, because I used exactly the same code that works fine for my friend but not for my account.
    Tuesday, February 04, 2014 8:34 AM
  • hi,

    Where did you get the Customer ID? you could get the Customer ID and Primary Account Key from this page https://datamarket.azure.com/account . How do you authenticate your account in code? In order for me to better understand your problem please share more code about authentication. NOTE: Hidden your account information.

    Regards,

    Will


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, February 05, 2014 8:53 AM
  • Here is the code:

    <?php
    
    class Microsoft_Translator {
    
        private $authToken;
    
        public function getTokens($grantType, $scopeUrl, $clientID, $clientSecret, $authUrl) {
    
            $ch = curl_init();
    
            $paramArr = array(
                'grant_type' => $grantType,
                'scope' => $scopeUrl,
                'client_id' => $clientID,
                'client_secret' => $clientSecret
            );
            $paramArr = http_build_query($paramArr);
    
            curl_setopt($ch, CURLOPT_URL, $authUrl);
            curl_setopt($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $paramArr);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
            $strResponse = curl_exec($ch);
    
            $curlErrno = curl_errno($ch);
            if ($curlErrno) {
                $curlError = curl_error($ch);
                throw new Exception($curlError);
            }
    
            curl_close($ch);
    
            $objResponse = json_decode($strResponse);
            if (isset($objResponse->error) && $objResponse->error) {
                throw new Exception($objResponse->error_description);
            }
    
            return $objResponse->access_token;
        }
    
    }
    
    $translator = new Microsoft_Translator();
    $translator->getTokens('client_credentials', 'http://api.microsofttranslator.com', 'trsearchtranslator', PRIVATE_KEY, 'https://datamarket.accesscontrol.windows.net/v2/OAuth2-13/');

    This code works fine for my friend with his keys, but for my account it returns error.

    Wednesday, February 05, 2014 9:45 PM
  • Hi,

    Sorry, may be my first post mislead you.

    Please see this tutorials to get the Client ID and Client Secret (http://blogs.msdn.com/b/translation/p/gettingstarted1.aspx ) and this (http://msdn.microsoft.com/en-us/library/ff512421.aspx ).

    Please try it.

    If I misunderstand, please let me know.

    Regards,

    Will


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, February 07, 2014 6:41 AM