I am doing project in laravel 5.2. For authentication, I am using API Token Authentication from Laravel 5.2. I have referred https://gistlog.co/JacobBennett/090369fbab0b31130b51 and my code looks like,
Routes.php
Route::post('login/','UserController@login');
Route::group(['prefix' => 'api/v1', 'middleware' => 'auth:api'], function () {
Route::get('/', function () {
return "Hi";
});
});
and in UserController.php I did simple login as follows,
public function login(Request $request){
$email = $request->input('email');
$user = DB::table('users')->where('email',$email)->first();
return $user->api_token;
}
I am using postman and first I did login and it returns me the correct api_token from table but when I try to access urls within middleware then it throws an error page as,
Sorry, the page you are looking for could not be found.
1/1
NotFoundHttpException in RouteCollection.php line 161:
I tried, localhost:8888/ as well as
localhost:8888/api_token=6CnUsIKlmwHXYQNFAuhUTDweUe707gJU2nM2j1Kwjn80nFgmaJHGXuAdN3BX
But still it shows same error page.