Tcl
Tcl
Get the JWS Payload as a String
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.GetPayload, which returns the payload of a loaded JWS as text, decoded using the given charset.
Background. In practice, validate the signature before trusting the payload. Getting the payload retrieves the signed content.
Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
set jws [new_CkJws]
# Load the JWS compact serialization.
set jwsCompact "eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>"
set success [CkJws_LoadJws $jws $jwsCompact]
if {$success == 0} then {
puts [CkJws_lastErrorText $jws]
delete_CkJws $jws
exit
}
# Return the JWS payload as text, decoded using the given charset.
set payload [CkJws_getPayload $jws "utf-8"]
if {[CkJws_get_LastMethodSuccess $jws] == 0} then {
puts [CkJws_lastErrorText $jws]
delete_CkJws $jws
exit
}
puts "$payload"
delete_CkJws $jws