Thursday, 02 January 2025
  3 Replies
  12 Visits
  Subscribe
I'm trying to use the TsgcHTTP_JWT_Client component to connect to Coinbase using TsgcWSAPI_Coinbase. So far I have not been able to make the authentication work. I followed the code provided in sgcJWT_Client sample project:


procedure TForm1.Button1Click(Sender: TObject);
begin
sgcWSAPI_Coinbase1.Coinbase.ApiKey := edAPIKey.Text;
sgcWSAPI_Coinbase1.Coinbase.ApiSecret := edAPISecret.Text;

sgcHTTP_JWT_Client1.JWTOptions.Header.alg := TsgcHTTP_JWT_Algorithm.jwtRS256; // TsgcHTTP_JWT_Algorithm(cboAlgorithm.ItemIndex + 1);
sgcHTTP_JWT_Client1.JWTOptions.Payload.iss := 'cbd';
sgcHTTP_JWT_Client1.JWTOptions.Payload.iat := StrToInt(GetDateTimeUnix(Now, False));
sgcHTTP_JWT_Client1.JWTOptions.Payload.nbf := StrToInt(GetDateTimeUnix(Now, False));
sgcHTTP_JWT_Client1.JWTOptions.Payload.exp := StrToInt(GetDateTimeUnix(Now, False));

sgcWebSocketClient1.Authentication.Enabled := True;
sgcWebSocketClient1.Authentication.URL.Enabled := False;
sgcWebSocketClient1.Authentication.Token.Enabled := True;
sgcWebSocketClient1.Authentication.Token.JWT := sgcHTTP_JWT_Client1;

sgcWebSocketClient1.Active := True;
end;


It looks like the Authentication header is not handled properly.

What am I doing wrong?

Greetings