Authentication error delphi RRS feed

  • Question

  • I am using the follow code

     clHttp1.Request.Header.ContentType := 'application/x-www-form-urlencoded';
        clHttp1.Request.Header.Authorization:='Basic ' + Encode64(AccountKey + ':' + AccountKey);
        clHttp1.Post('https://api.datamarket.azure.com/Bing/MicrosoftTranslator/v1/Translate?Text=%27developer%27&To=%27es%27&From=%27en%27', value);
          on e: Exception do

    It created the follow request

    POST /Bing/MicrosoftTranslator/v1/Translate?Text=%27developer%27&To=%27es%27&From=%27en%27 HTTP/1.1
    Accept: */*
    Authorization: Basic OtHcLLGvU6vEGsKrP4PgR59aDsTHM4XHCNX2OrDGH5TYHKbgQb99CbHpRpfZT6PLL3buRav3PJLaHcfiKcGtPr5OI54nU49ZKr14Ls95IMfgKaaoL7Dl
    Content-Length: 110
    Content-Type: application/x-www-form-urlencoded
    Accept-Encoding: gzip, deflate
    Host: api.datamarket.azure.com
    User-Agent: Mozilla/4.0 (compatible; Clever Internet Suite)
    Connection: Keep-Alive

    and result getting is 

    HTTP/1.1 401 The authorization type you provided is not supported.  Only Basic and OAuth are supported
    Server: Microsoft-IIS/8.0
    X-Content-Type-Options: nosniff
    WWW-Authenticate: Basic Realm=""
    X-Powered-By: ASP.NET
    Access-Control-Allow-Origin: *
    Access-Control-Allow-Credentials: false
    Access-Control-Allow-Headers: Authorization, DataServiceVersion, MaxDataServiceVersion
    Access-Control-Expose-Headers: DataServiceVersion, MaxDataServiceVersion
    Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
    Access-Control-Max-Age: 604800
    Date: Wed, 19 Nov 2014 11:11:36 GMT
    Content-Length: 91

    So, what i am doing wrong?

    Thanks in advance

    Wednesday, November 19, 2014 11:13 AM

All replies

  • Hi,

    It seems you using the same call for both Authentication and translation. This is not supported.

    Auth for Translator is a two-step process :

    1. Acquire auth token (valid for 10 mins) using client ID and secret, then
    2. Translate using an HTTP header value of “Bearer $authToken”.

    You cannot use basic auth to authenticate and translate in the same call.

    We hope this helps.


    Microsoft Translator team - www.microsoft.com/Translator

    Saturday, November 22, 2014 12:26 AM