Rest 带有Delphi的Coinbase Pro API(签名无效)

Rest 带有Delphi的Coinbase Pro API(签名无效),rest,api,delphi,get,coinbase-api,Rest,Api,Delphi,Get,Coinbase Api,我正试图使用Delphi10.3和其他组件向Coinbase Pro发出“获取”请求 如文档中所述 我总是收到以下消息:签名无效。 我已经检查了好几次了,但都找不到错误。也许这是个问题 使用Base64对密钥和CB-ACCESS-SIGN头中的字符串进行de/编码? sha256 HMAC编码和时间戳似乎运行良好。 其余的标题似乎也没有问题 这是我的密码。钥匙是旧的,仅作为示例: unit Unit1; interface uses Winapi.Windows, Winapi.Mess

我正试图使用Delphi10.3和其他组件向Coinbase Pro发出“获取”请求 如文档中所述

我总是收到以下消息:签名无效。 我已经检查了好几次了,但都找不到错误。也许这是个问题 使用Base64对密钥和CB-ACCESS-SIGN头中的字符串进行de/编码? sha256 HMAC编码和时间戳似乎运行良好。 其余的标题似乎也没有问题

这是我的密码。钥匙是旧的,仅作为示例:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,IdHashSha, Vcl.StdCtrls,IdSSLOpenSSL,IdGlobal,IdHMAC,IdHMACSHA1,
  REST.Types, Data.Bind.Components, Data.Bind.ObjectScope,  REST.Client,EncdDecd,system.netencoding,json,idcoder,idcodermime;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button2: TButton;
    RESTClient1: TRESTClient;
    RESTRequest1: TRESTRequest;
    RESTResponse1: TRESTResponse;
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }

 function CalculateHMACSHA256(const value, skey: String): String;
 function DateTimeToUnix(ConvDate: TDateTime): Longint;
 function GetCurrentDateTime: TDateTime;
 procedure stringcreate;

end;
var
  Form1: TForm1;
  timestamp:string;
  date:tdatetime;
  skeydecode:string;
  sha256:string;
  encode:string;
  prehash:string;
  implementation
const UnixStartDate: TDateTime = 25569.0;
const skey:string='iG8mrRLIT9EGw0gMxjxo55U74RtAQeSUal28+VR+STmWvtrTGNunfL19M9M3mmPpBsJLu7LZmrFskb3q42ditQ==';
const apikey:string='3a829c8b4bddb75fb372183a5f63f2a4';
const passphrase:string='eevj5njvs65';


{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
var
  jValue:TJSONValue;

begin
stringcreate;
restclient1.BaseURL:='https://api.pro.coinbase.com/accounts';
restrequest1.Params.AddHeader('CB-ACCESS-KEY',apikey);
restrequest1.Params.AddHeader('CB-ACCESS-SIGN',encode);
restrequest1.Params.AddHeader('CB-ACCESS-TIMESTAMP',timestamp);
restrequest1.Params.AddHeader('CB-ACCESS-PASSPHRASE',passphrase);

RESTRequest1.Execute;
jValue:=RESTResponse1.JSONValue;
edit1.Text:= jValue.ToString;
end;

function tform1.CalculateHMACSHA256(const value, skey: String): String;
var
hmac: TIdHMACSHA256;
hash: TIdBytes;
begin
LoadOpenSSLLibrary;
if not TIdHashSHA256.IsAvailable then
showmessage('Error');
hmac := TIdHMACSHA256.Create;
try
hmac.Key := IndyTextEncoding_UTF8.GetBytes(skey);
hash := hmac.HashValue(IndyTextEncoding_UTF8.GetBytes(value));
Result := ToHex(hash);
finally
hmac.Free;
end;
end;

function tform1.DateTimeToUnix(ConvDate: TDateTime): Longint;
begin
 Result := Round((ConvDate - UnixStartDate) * 86400);
end;

 function tform1.GetCurrentDateTime: TDateTime;
var
  SystemTime: TSystemTime;
begin
  GetSystemTime(SystemTime);
  Result := system.SysUtils.Systemtimetodatetime(SystemTime);
end;

procedure tform1.stringcreate;
begin
date:=strtodatetime(system.SysUtils.DateTimeToStr(GetCurrentDateTime));
timestamp:=inttostr(DateTimeToUnix(date));
skeydecode:=TIdDecoderMIME.DecodeString(skey);
prehash:=timestamp+'GET'+'/accounts';
sha256:=CalculateHMACSHA256(prehash ,skeydecode);
encode:=Tidencodermime.EncodeString(sha256);

end;


end.
你能帮我吗