JWS.VERIFY

JWS.VERIFY will verify the signature of a JWT and extract the payload as a string, wrapping it in a data envelope.

Function category: JWT

Syntax

JWS.VERIFY(arg1, arg2, arg3, [args...])

Arguments

Description

arg1

String denoting the algorithm to be used.

arg2

String of the input data to verify

arg3

String of the expected signature

[args...]

Additional set of arguments for usage with certain subsets of algorithms

Example

Let's say we have the following JWT.

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.
EpM5XBzTJZ4J8AfoJEcJrjth8pfH28LWdjLo90sYb9g

If we receive a signed JWT that we want to verify, we can simply use the JWS.VERIFY token to verify the sender and extract the payload. By calling JWS.VERIFY on the above JWT, we can ensure that it was signed with the password provided.

JWS.VERIFY('HS256',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.EpM5XBzTJZ4J8AfoJEcJrjth8pfH28LWdjLo90sYb9g',
'password')

This returns the following.

{ payload: "{\"foo\" 1 \"bar\" [4 5 \"qwe\"] }" }

Notes

If JWS.VERIFY encounters an error, it will return a response with the following structure:

{ error: error_description }

error_description will be a string describing the nature of the error encountered.