API Token Creation For Authentication In Laravel 5.2

Submitted by azazqadir - 3 months ago

In this article, I will discuss Laravel API token authentication, a very important topic in web app and website security. I will demonstrate the basis of API token authentication and how easily you could implement the idea in your project. To demonstrate the idea, I will make a simple application, in which users can register themselves, and by using their api tokens, will try to post some data into the database. If Laravel API Guard allows the token, the data will be posted to the database. If the token is rejected, an exception is thrown. Source: https://www.cloudways.com/blog/api-token-authentication-laravel-5-2/

$ vim /app/Note.php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Note extends Model
   protected $fillable = ['text', 'user_id',];
   protected $hidden = ['user_id',];
comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks