使用delphi获取eBay Access令牌

时间:2018-01-10 08:35:20

标签: rest api delphi ebay

使用delphi获取eBay访问令牌时遇到问题。

当我运行它并点击按钮时,我应该获得访问令牌,但我得到了

  

异常EHTTPProtocolException'HTTP / 1.1 401 Unauthorized'

当我点击继续。消息对话框显示meessege

  

{“error”:“invalid_client”,“error_description”:“客户端身份验证   失败“}

我的delphi代码:

procedure TForm5.btn1Click(Sender: TObject);
var
 vClientId, vClientSecret : string;
 vBase64 : String;
 vRuNames : string;
begin
  vClientId:='jackjump-xxxx-SBX-15d7a0307-68d66d5a';
  vClientSecret:='SBX-5d7a03073f13-cb20-4a72-b71e-4e53';
  vBase64:=TNetEncoding.Base64.Encode(vClientId+':'+vClientSecret);
  vRuNames:='jack_jumping-jackjump-xxxx--tbccomu';

  RESTRequest1.Method:=rmPOST;
  RESTRequest1.Resource:='/identity/v1/oauth2/token';    
  RESTRequest1.AddParameter('Authorization', 'Basic '+vBase64, pkHTTPHEADER);
  RESTRequest1.AddParameter('grant_type','client_credentials', pkREQUESTBODY);
  RESTRequest1.AddParameter('redirect_uri',vRuNames, pkREQUESTBODY);
  RESTRequest1.AddParameter('scope','https://api.ebay.com/oauth/api_scope', pkREQUESTBODY);


  RESTRequest1.Execute;
  ShowMessage(RESTResponse1.Content);
end;

0 个答案:

没有答案