Api Restful laravel 5.2

1

Hello,

I'm trying to create an api in laravel 5.2

What I'm trying to do is the following:

1 - Continue using the 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 required to know the token of the user and what I wanted was the following in the api user type the user and password gives with this I would return the token and he could access their pages or registers 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

    
asked by anonymous 16.06.2016 / 06:04

2 answers

1

To get the initial token, you need to create a route outside of the group that uses auth.api middleware

A simple route like api/authenticate that receives the user data and returns the token, if the login is done successfully

    
08.07.2016 / 03:09
-1

The solution to my problem was the link: laravel-jwt-auth

    
16.06.2016 / 22:15