Sample code for 30+ languages & platforms
Tcl

Get the JWS Payload into BinData

See more JSON Web Signatures (JWS) Examples

Demonstrates Jws.GetPayloadBd, which writes the payload of a loaded JWS as raw bytes into a BinData.

Background. This is used when the payload is binary. In practice, validate the signature before trusting the payload.

Chilkat Tcl Downloads

Tcl

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
}

#  Get the JWS payload as raw bytes into a BinData.
set bdPayload [new_CkBinData]

set success [CkJws_GetPayloadBd $jws $bdPayload]
if {$success == 0} then {
    puts [CkJws_lastErrorText $jws]
    delete_CkJws $jws
    delete_CkBinData $bdPayload
    exit
}

puts "Payload is [CkBinData_get_NumBytes $bdPayload] bytes."

delete_CkJws $jws
delete_CkBinData $bdPayload