What Am I trying?
I already have a website and I am trying Token based authentication 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'], function () {
Route::post('/apilogin', 'AccountController@apilogin');
});
Then from the Postman Chrome Extension, I have below info for Headers
Cache-Control →no-cache, private
Connection →close
Content-Type →text/html; charset=UTF-8
Date →Mon, 23 May 2016 05:20:56 GMT
Server →Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.14
Transfer-Encoding →chunked
X-Powered-By →PHP/5.6.14
Body info is like below
{"UserName": "Pankaj"}
When I press Send: I get below Error
TokenMismatchException in VerifyCsrfToken.php line 67:
Am I missing something?
config/auth.php is below
<?php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User\UserModel::class,
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'email' => 'emails.password',
'table' => 'resetpassword',
'expire' => 60,
],
],
];
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire