I'm trying to parse a custom JWT token. To generate the token i have the following class:
public function createToken()
{
$client = ['sub' => 'u0406'];
$payload = JWTFactory::make($client);
$token = JWTAuth::encode($payload);
return $token;
}
I get this token and passing it
How can i parse this and get the variable $client in another method?
My parseMethod is declared like this:
public function create(Request $request)
{
$token = JWTAuth::getToken();
return $token;
}
And it just returns the token string. Not the array.
I suppose you succeeded in creating your token in the createToken() method and you are passing it in a request to the create() method inside which you want to parse that token to get the client object/associative array again.
From what you are wrote, I think you are using the wrong method on the JWTAuth, which is getToken(). To do the parsing right, try this
Instantiate a $jwtauth object from the JWTAuth class first
In your create method access the client/user by using $client = jwtauth->toUser($token);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With