DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoJws
String sJwsCompact
String sPayload
String sTemp1
Boolean bTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatJws)) To hoJws
If (Not(IsComObjectCreated(hoJws))) Begin
Send CreateComObject of hoJws
End
// Load the JWS compact serialization.
Move "eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>" To sJwsCompact
Get ComLoadJws Of hoJws sJwsCompact To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoJws To sTemp1
Showln sTemp1
Procedure_Return
End
// Return the JWS payload as text, decoded using the given charset.
Get ComGetPayload Of hoJws "utf-8" To sPayload
Get ComLastMethodSuccess Of hoJws To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoJws To sTemp1
Showln sTemp1
Procedure_Return
End
Showln sPayload
End_Procedure