Reputation: 105
I am facing a problem to decode token (JWT). Here it's encoded successfully and it provides me with a token. My code code is:
$tokenData = $this->set([
'data' => [
'token' => JWT::encode([
'sub' => $user['username'],
'exp' => time() + 202200
],
Security::salt())
],
'_serialize' => ['success', 'data']
]);
It returns "token":{"token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
To decode this I used:
$JWT_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$token = JWT::decode($JWT_KEY);
dd($token);
How can I get it? specially time. Thanks in advance
Upvotes: 0
Views: 675
Reputation: 11
if you are using firebase JWT take a look to: https://github.com/firebase/php-jwt
for me that command worked, here's a piece of my code:
$jwt= $this->request->data['_token']; $decoded = JWT::decode($jwt, $this->pepper, array('HS256'));
//$decoded is an object with your token decoded data
Upvotes: 1