there are some threads relating to jwt, but i didn't see any libraries.
so i made a small one.  it is based on your parameters.

your token was not quite complete.  in addition to a payload and a key
you need a header.  i've added one based on your parameters.

your payload is a simple one, so it is possible to create a json string, but
there is a correct one to generate and parse json strings with our json 
library.  i'm sure you know how to use it.  for the purposes of creating a jwt
for you, i've left your payload as you built it.  if you were making a more
robust jwt, you would need an expanded payload.  i think my little library
can handle that.

i've verified the jwt at https://https://jwt.io/

my example displays the jwt in the log and in a label.  if you copy the 
output from the log, you can paste it at jwt.io to check the token yourself.

the attached .zip archive includes the example and the library's .jar/.xml
copy the .jar and .xml to your additional libraries folder.  the example runs
for me, no problem.