I am working with a laravel api, it strictly deals with ajax requests. After successful login, the client will receive a laravel passport token for sequential requests.
The api has this route which simply return the authenticated user's details:
Route::group(['middleware' => 'auth:api'], function() {
Route::post('/user/details', 'API\UserController@details');
});
// in UserController...
public function details() {
$user = Auth::user();
return response()->json([
'user' => $user
], 201);
}
When i use postman to test my api, i get this response if i adding:
{Accept: application/json, Authorization: "Bearer " + LARAVEL_PASSPORT_TOKEN}
to the request header:
but if i only have {Accept: application/json} in the header. It will give me back a normal Json unauthenticated response.
So, it would be great if someone knows what is going on and give me some insight about it.
Thanks in advance.