Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oJws
LOCAL cJwsCompact
LOCAL cPayload
nSuccess := 0
oJws := CreateObject("Chilkat.Jws")
// Load the JWS compact serialization.
cJwsCompact := "eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>"
nSuccess := oJws:LoadJws(cJwsCompact)
IF (nSuccess == 0)
? oJws:LastErrorText
oJws:destroy()
RETURN
ENDIF
// Return the JWS payload as text, decoded using the given charset.
cPayload := oJws:GetPayload("utf-8")
IF (oJws:LastMethodSuccess == 0)
? oJws:LastErrorText
oJws:destroy()
RETURN
ENDIF
? cPayload
oJws:destroy()