Generating and Decoding JWT with Arduino

Hello, I am trying to encode and decode JWT on the Arduino platform but I am having trouble performing this successfully. I am using the library found here. There isn't much documentation and I don't seem to be producing valid tokens nor decoding properly.

Does anyone have experience with JWT and Arduino and can help troubleshoot this project or can push me in a separate direction?

Below is my code:

String key1="s97931a53932490f48a34c524c8f6ca22db80674869b3eaa42b7fdc25065aec86";
ArduinoJWT giv= ArduinoJWT("sc0b52aa215ded9c92e0db5dcedcc4843e4fb565552e9910a5398d08f3a492f43");
String msg="encode and decode this";
String payload;

void setup() {
 Serial.begin(9600);

 jwt.setPSK(key1);


}

void loop() {
  // put your main code here, to run repeatedly:
   Serial.println(msg);
   payload = giv.encodeJWT(msg);
   Serial.println(payload);
   delay(2000);
   payload = giv.decodeJWT(key1, payload);
   Serial.println(payload);
   delay(2000);

}
1 Like