TsgcHTTP_OAuth2_Client › Methods › PublicKeyToJWK
Converts a PEM-encoded public key to its JWK (JSON Web Key) representation.
function PublicKeyToJWK(const aPEM: String): String;
| Name | Type | Description |
|---|---|---|
aPEM | const String | A PEM-encoded public key (EC P-256 or RSA) to be converted to JWK. |
The public key serialized as a JWK JSON string (for example {"kty":"EC","crv":"P-256","x":"...","y":"..."}), suitable for assignment to DPoPOptions.PublicKeyJWK or for registration with the authorization server.
Use this helper when you already have an externally generated key pair and need to publish the public half in JWK form (for example to register a client assertion key or to populate DPoPOptions.PublicKeyJWK without calling GenerateDPoPKeyPair). The input must be a single PEM block containing -----BEGIN PUBLIC KEY-----/-----END PUBLIC KEY-----.
var
vJWK: String;
begin
vJWK := oAuth2.PublicKeyToJWK(oAuth2.DPoPOptions.PrivateKey.Text);
oAuth2.DPoPOptions.PublicKeyJWK := vJWK;
end;