DeveloperBreeze

Api Authentication Development Tutorials, Guides & Insights

Unlock 2+ expert-curated api authentication tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your api authentication skills on DeveloperBreeze.

Tutorial

Creating Personal Access Tokens for a Custom Model in Laravel

use Laravel\Sanctum\HasApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Customer extends Authenticatable
{
    use HasApiTokens;

    protected $fillable = ['name', 'email'];

    // Define the relationship with tokens
    public function tokens()
    {
        return $this->morphMany(\Laravel\Sanctum\PersonalAccessToken::class, 'tokenable');
    }
}

The HasApiTokens trait adds the ability to issue tokens to the Customer model.

Oct 24, 2024
Read More
Tutorial
php

بناء API متقدم باستخدام Laravel Passport للتوثيق

افتح ملف app/Providers/AuthServiceProvider.php وأضف Passport إلى إعدادات الحماية:

use Laravel\Passport\Passport;

public function boot()
{
    $this->registerPolicies();

    Passport::routes();
}

Sep 27, 2024
Read More