I am working on a Login with Laravel Passport to later consume this API in Angular and i find the following problem
When I throw a GET in Postman to the following path http://127.0.0.1:8000/api/tramites with the Accept: application / json headers and my Authorization token: Bearer xxxx it returns me
"message": "Unauthenticated."
I do not understand why this happens since I am passing the generated user token, it would have to access.
api.php
Route::group(['middleware' => 'auth:api'], function(){
Route::ApiResource('tramites', 'TramiteController');});
PersonaController.php
public function login(Request $request)
{
$persona = Persona::whereUsuario($request->Usuario)->first();
if(!is_null($persona) && ($request->Contrasena == $persona->Contrasena))
{
$persona->App_Id = Str::random(100);
$persona->save();
return response()->json([
'res' => true,
'token' => $persona->App_Id,
'message' => 'Login succesfully'
], 200);
}
else{
return response()->json([
'res' => false,
'message' => 'Login wrong'
], 400);
}
}