Laravel Passport cannot find a personal access client
Personal access client not foundShort answer
createToken needs a personal access client, and the database you are connected to does not have one. Create it with php artisan passport:client --personal. If your app has several user providers, pass --provider so the client matches the model that calls createToken. Run it once on each environment.
Fix it fast
1Find out which cause you have
Confirm you are looking at the right database, then see whether any client exists. The error means the oauth_clients table has no personal access client for this app.
php artisan tinker >>> DB::table('oauth_clients')->get(['id','name','grant_types'])2Match what you see, then jump to its fix
- 1
The oauth_clients table is empty, or it has no row with the personal_access grant.No personal access client was ever created on this databaseFix - 2
A client exists, but the app has more than one provider in config/auth.php and createToken is called on the model of the other one.The client belongs to a different user provider than the model you callFix - 3
createToken is not defined on the model at all, and the model has no Passport trait.The user model does not use Passport's HasApiTokens traitFix
- 1
What does the error look like?
Personal access client not foundcreateToken fails for a user, and no token is returned
Cause 1 of 3
No personal access client was ever created on this database
1Check
Passport does not make this client during migration. It is made by a command. A new server, a fresh database or a restored dump that skipped the table all lack it.
php artisan tinker
>>> DB::table('oauth_clients')->count()2Fix
Create the client with the Passport command. If you already ran passport:install, this step is not needed.
php artisan passport:client --personal3Verify
Issue a token again for a real user.
php artisan tinker
>>> App\Models\User::first()->createToken('My Token')->accessTokenConfirmed by laravel.com
Cause 2 of 3
The client belongs to a different user provider than the model you call
1Check
Passport ties a personal access client to one user provider. Compare the providers in config/auth.php with the model whose createToken you call.
grep -n -A4 "'providers'" config/auth.php2Fix
Create a personal access client for the provider that matches your model, using the provider name from config/auth.php.
php artisan passport:client --personal --provider=admins3Verify
createToken on the second model now returns a token.
php artisan tinker
>>> App\Models\Admin::first()->createToken('My Token')->accessTokenConfirmed by laravel.com
Cause 3 of 3
The user model does not use Passport's HasApiTokens trait
1Check
createToken is a method of the Laravel\Passport\HasApiTokens trait. The Passport docs ask you to add this trait and the OAuthenticatable interface to your user model.
grep -n "HasApiTokens" app/Models/User.php2Fix
Import the trait from Passport, and add the OAuthenticatable interface shown in the docs.
use Laravel\Passport\Contracts\OAuthenticatable;
use Laravel\Passport\HasApiTokens;
class User extends Authenticatable implements OAuthenticatable
{
use HasApiTokens, HasFactory, Notifiable;
}3Verify
Run createToken again from tinker.
php artisan tinker
>>> App\Models\User::first()->createToken('My Token')->accessTokenConfirmed by laravel.com
How do I stop it coming back?
- Add php artisan passport:client --personal to your server setup notes next to passport:keys.
- After restoring a database dump, check that the oauth_clients table came with it.
- If you only need personal tokens for your own API, read the Passport docs' note about Laravel Sanctum, which is lighter.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fixBack end
Composer says the root composer.json requires a PHP version your PHP does not satisfy
Your requirements could not be resolved to an installable set of packages.
Composer compares the php constraint in your composer.json, or in a package, with the PHP that runs Composer.
3 causes, each with a fix