0
votes

I am able to access routes declared in the api.php(route) with middleware 'api'. But not able to do the same with the routes that has 'auth:api'. I guess only authenticated users can access the latter route. But when i access it after logging in , it just redirects me to home. how to fix this or am i following wrong procedure ?

Route::get('/user', function () {
echo "Hello";
})->middleware('auth:api');

Route::get('/work',function(){
echo "Hello";
})->middleware('api');
1
When you are using auth:api you have to pass access_token as parameter string and access_token field should be exist in Database Table. @NaveenKumar - PassionInfinite
Maybe the documentation can help a bit laravel.com/docs/5.3/passport - PKeidel

1 Answers

0
votes

Check Laravel passport, it provides a nice way to implement OAuth2 and once you install passport create password client and make a post request to Oauth/token and get personal access_token.

Once you have the access_token you can make request to middleware auth:api