Reputation: 686
I'm working with JWT authentication using Laravel 6 and vue.js 2, and jwt package: tymon/jwt-auth. I'm testing my api using postman. But it returns "1" instead access_token
. Could anyone please help me with it? Following is api method:
public function loginMe(Request $request)
{
$credentials = $request->only('email', 'password');
try {
if (!$token = JWTAuth::attempt($credentials)) {
return response()->json([
'success' => false,
'message' => 'Login credentials are invalid.',
], 400);
}
} catch (JWTException $e) {
return response()->json([
'success' => false,
'message' => 'Could not create token.',
], 500);
}
return response()->json([
'success' => true,
'access_token' => $token,
]);
}
Upvotes: 0
Views: 80
Reputation: 16
Often the problem is on header.
Try to add in the Postman request, in the header:
Upvotes: 0