Hello,
I work on laravel 5.0. everything has been installed.. but when I try this example code.. I got empty token:
Controller:
$payload = app('tymon.jwt.payload.factory')->sub(123)->aud('foo')->foo(['bar' => 'baz'])->make();
$token = JWTAuth::encode($payload);
return Response::json(['success' => 1, 'message' => 'User is already register.', 'token' => $token], 200);
{"success":1,"message":"User is already register.","token":{}}
Any idea ?
what output do you get when you call dd($token); before returning the response ?
it should be an instance of Tymon\JWTAuth\Token, so it appears the __toString() method isn't firing in this case.
The following should work too
return Response::json(['token' => $token->get()]);
Most helpful comment
what output do you get when you call
dd($token);before returning the response ?it should be an instance of
Tymon\JWTAuth\Token, so it appears the__toString()method isn't firing in this case.The following should work too