What Am I trying?
I already have a website and I am trying Token based authentication for an API in same code and below is the start for sample authentication code
I created a controller below is the code.
class AccountController extends \App\Http\Controllers\Controller
{
public function apilogin($UserData) {
return json_decode($UserData);
}
}
My route config is below.
Route::group(['prefix' => 'api/v1', 'middleware' => 'auth.api'], function () {
Route::post('/apilogin', 'API\User\Account\AccountController@apilogin');
});
**Then from the Postman Chrome Extension, I have posted the request and worked fine if I comment the following line from $middlewareGroups in Kernel.php
\App\Http\Middleware\VerifyCsrfToken::class,
I have no issues VerifyCsrfToken if I do GET request from POSTMan Extension
Open your app\http\Middleware\VerifyCsrfToken.php
file.
Here edit $except
property with:
protected $except = [
'api/*'
];
This will exclude your api routes from CSRF verification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With