1
Hello,
I am trying to create an api in Laravel 5.2
what I’m trying to do is this:
1 - continue using default auth system for web user.
2 - create an api for users of an application.
I am using the method: auth:api, but with this method I am obliged to know the user token and what I wanted is the following in the api the user type the user and password dai with this would return me the token and he could access their pages or entries etc...
my route.php
Route::get('/', function () {
return redirect('/home');
});
Route::auth();
Route::get('/home', 'HomeController@index');
Route::group(['prefix' => 'api/v1', 'middleware' => 'auth:api'], function () {
Route::get('/', function () {
return Auth::guard('api')->user();
});
});
thank you
Have you thought about using jwt? See here: https://github.com/code-sample/laravel-jwt-auth
– Evert
@Evert thank you so much for the link, apparently this all ok. Thank you
– Douglas Salomão