验证错误delphi [英] Authentication error delphi

查看:105
本文介绍了验证错误delphi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码

 clHttp1.Request.Header.ContentType := 'application/x-www-form-urlencoded';
 try
    AccountKey:=Account;
    clHttp1.Request.AddFormField('client_id',clientValue);
    clHttp1.Request.AddFormField('client_secret',AccountKey);
    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);
except
      on e: Exception do
        ShowMessage(e.Message);
end;

它创建了以下请求

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

那么,我做错了什么?

提前致谢

推荐答案

您似乎使用相同的调用进行身份验证和转换。这不受支持。

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

Auth for Translator分为两步:


  1. 使用客户端ID和密码获取身份验证令牌(有效期为10分钟),然后
  2. 使用HTTP标头值"Bearer
  1. Acquire auth token (valid for 10 mins) using client ID and secret, then
  2. Translate using an HTTP header value of "Bearer


authToken"进行翻译。
authToken".

您不能使用基本身份验证在同一个呼叫中进行身份验证和翻译。

我们希望这会有所帮助。

We hope this helps.

Olivier


这篇关于验证错误delphi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆