firebase/php-jwt throws Signature verification failed error on every scenario in PHP 7.4

360 Views Asked by At

I've installed firebase/php-jwt as described in the repo. In composer file.

"firebase/php-jwt": "~5.5.1",
"paragonie/sodium_compat" : "~1.19.0",

In my PHP file

$jwtSecret = "785373b58697498280905a4c9382ce8b4c9382ce8bsds234sd785373b58697498280905a4c9382ce8b2324c9382ce8b234sds24";
$payload =[
   "item1" => 1900,
   "item2" => 1800,
];

$jwt = JWT::encode($payload, $jwtSecret, 'HS512');
print_r(['jwt' => $jwt]);


$decoded = JWT::decode($jwt,$jwtSecret, array('HS512'));

print_r(['decode' => $decoded]);

It throws Signature verification failed error. but JWT.IO says Signature Verified by the same $jwtSecret without base64 encoded.

I almost tried every other solutions from SO, but nothing seems working. Can you please find what's wrong here?

0

There are 0 best solutions below