{"id":19430696,"url":"https://github.com/jmrashed/laravel-sanctum-api-authentication-","last_synced_at":"2026-05-12T20:09:01.954Z","repository":{"id":84181394,"uuid":"543981596","full_name":"jmrashed/laravel-sanctum-api-authentication-","owner":"jmrashed","description":"laravel sanctum api authentication ","archived":false,"fork":false,"pushed_at":"2022-10-01T19:19:43.000Z","size":77,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-07T20:14:39.482Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmrashed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-01T10:17:47.000Z","updated_at":"2022-10-01T10:26:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"8e8170c8-c4ae-4eb0-bd64-1a31742221e4","html_url":"https://github.com/jmrashed/laravel-sanctum-api-authentication-","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Flaravel-sanctum-api-authentication-","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Flaravel-sanctum-api-authentication-/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Flaravel-sanctum-api-authentication-/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Flaravel-sanctum-api-authentication-/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmrashed","download_url":"https://codeload.github.com/jmrashed/laravel-sanctum-api-authentication-/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240612535,"owners_count":19829027,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T14:26:05.818Z","updated_at":"2026-05-12T20:08:56.922Z","avatar_url":"https://github.com/jmrashed.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Welcome to the Laravel API Authentication Using LARAVEL SANCTUM- wiki!\n\n## Make REST API AUTHENTICATION in LARAVEL 9 USING LARAVEL SANCTUM\nLaravel Sanctum provides a featherweight authentication system for SPAs (single page applications), mobile applications, and simple, token based APIs.\nInstallation Steps\nIf you are not using LARAVEL 9 you need to install LARAVEL Sanctum Otherwise you can skip the installation step.\n\n### Step 1 \nInstall via composer\n`composer require laravel/sanctum`\n\n\n### Step 2\nPublish the Sanctum Service Provider\n`php artisan vendor:publish --provider=\"Laravel\\Sanctum\\SanctumServiceProvider\"`\n\n\n\n### Step 3\nMigrate The Database\n`php artisan migrate`\n\n\n\n## USING SANCTUM IN LARAVEL\nUser HasApiTokens Trait in App\\Models\\User\nIn Order to use Sanctum we need to use HasApiTokens Trait Class in User Model.\nUser Model should look like.\n\n```php \n\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Contracts\\Auth\\MustVerifyEmail;\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\nuse Illuminate\\Notifications\\Notifiable;\nuse Laravel\\Sanctum\\HasApiTokens;\n\nclass User extends Authenticatable\n{\n    use HasApiTokens, HasFactory, Notifiable;\n\n    /**\n     * The attributes that are mass assignable.\n     *\n     * @var array\u003cint, string\u003e\n     */\n    protected $fillable = [\n        'name',\n        'email',\n        'password',\n    ];\n\n    /**\n     * The attributes that should be hidden for serialization.\n     *\n     * @var array\u003cint, string\u003e\n     */\n    protected $hidden = [\n        'password',\n        'remember_token',\n    ];\n\n    /**\n     * The attributes that should be cast.\n     *\n     * @var array\u003cstring, string\u003e\n     */\n    protected $casts = [\n        'email_verified_at' =\u003e 'datetime',\n    ];\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmrashed%2Flaravel-sanctum-api-authentication-","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmrashed%2Flaravel-sanctum-api-authentication-","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmrashed%2Flaravel-sanctum-api-authentication-/lists"}