Cliente JWT
Genera, firma y verifica JSON Web Tokens desde Delphi/C++Builder. Firmas HMAC, RSA y ECDSA, JWE cifrados al estilo PASETO, refresco automático y fácil integración con TsgcHTTP2Client / TsgcHTTPComponentClient.
Genera, firma y verifica JSON Web Tokens desde Delphi/C++Builder. Firmas HMAC, RSA y ECDSA, JWE cifrados al estilo PASETO, refresco automático y fácil integración con TsgcHTTP2Client / TsgcHTTPComponentClient.
Sign HS256/HS384/HS512, RS256/RS384/RS512, ES256/ES384, EdDSA tokens; decode incoming JWTs; auto-refresh near expiry; pair with the HTTP and HTTP/2 clients via Authentication.Token.JWT.
TsgcHTTP_JWT_Client
Windows, macOS, Linux, iOS, Android
Professional / Enterprise
Set Header.alg, Payload.iss / iat / exp, load the signing key, then attach the JWT client to your HTTP / HTTP/2 / WebSocket component as the bearer-token source.
uses
sgcHTTP, sgcBase_Helpers;
var
JWT: TsgcHTTP_JWT_Client;
begin
JWT := TsgcHTTP_JWT_Client.Create(nil);
JWT.JWTOptions.Header.alg := jwtES256;
JWT.JWTOptions.Header.kid := 'apple-key-id';
JWT.JWTOptions.Payload.iss := 'team-id';
JWT.JWTOptions.Payload.iat := StrToInt64(GetDateTimeUnix(Now, False));
JWT.JWTOptions.Algorithms.ES.PrivateKey.LoadFromFile('AuthKey_XXX.p8');
JWT.JWTOptions.RefreshTokenAfter := 40 * 60; // auto-mint every 40 min
ShowMessage(JWT.Token);
end;
// uses: sgcHTTP
TsgcHTTP_JWT_Client *JWT = new TsgcHTTP_JWT_Client(this);
JWT->JWTOptions->Header->alg = jwtES256;
JWT->JWTOptions->Header->kid = "apple-key-id";
JWT->JWTOptions->Payload->iss = "team-id";
JWT->JWTOptions->Algorithms->ES->PrivateKey->LoadFromFile("AuthKey_XXX.p8");
ShowMessage(JWT->Token);
A typed JWT mint-and-verify component with HMAC, RSA, ECDSA and EdDSA signatures, automatic refresh and a clean handoff to the HTTP / HTTP/2 / WebSocket components.
JWTOptions.Header.alg selects HS256/384/512, RS256/384/512, ES256/384/512, PS256/384/512 or EdDSA. Keys are loaded from PEM, P8 or in-memory streams.
JWTOptions.Payload.iss, sub, aud, exp, nbf, iat, jti are typed properties matching RFC 7519 — plus a free-form CustomClaims for vendor extensions.
RefreshTokenAfter tells the component to mint a new JWT after N seconds — useful for APNs ES256 tokens that Apple expects rotated within an hour.
Decode(token) parses an inbound JWT and verifies the signature against the configured keys; OnVerify fires with success/failure and the parsed payload.
Encrypted JWTs (JWE) per RFC 7516 are supported: AES-CBC, AES-GCM, RSA-OAEP and ECDH-ES key wrapping.
Pair with TsgcHTTP2Client or TsgcHTTPComponentClient by setting Authentication.Token.JWT — every outbound request gets a fresh signed bearer token.
Enlace directo a la referencia del componente, descarga el proyecto demo listo para ejecutar y la prueba gratuita.
| Ayuda en línea — TsgcHTTP_JWT_Client Referencia completa de propiedades, métodos y eventos de este componente. | Abrir | |
| Proyecto demo — Demos\20.HTTP_Protocol\05.JWT Proyecto de ejemplo listo para ejecutar. Se incluye en el paquete sgcWebSockets — descarga la prueba gratuita más abajo. | Abrir | |
| Documento técnico (PDF) Características, inicio rápido, ejemplos de código para Delphi y C++ Builder y referencias de fuentes primarias — solo este componente. | Abrir | |
| Manual de usuario (PDF) Manual completo que cubre todos los componentes de la biblioteca. | Abrir |