Passport laravel createToken Personal access client not found

LaravelLaravel Passport

Laravel Problem Overview


After setup of passport, I have configured and created a controller to manage Register-Login- and - access to a resource for a general external post request. I do not need for a specific client. But when I try to create a token in the registration or in the login:

$tokenObj=$user->createToken('APPLICATION')->accessToken;

The error is:

> RuntimeException: Personal access client not found. Please create one. in file > C:\xampp7.1\htdocs\passport\vendor\laravel\passport\src\ClientRepository.php > on line 94 > Stack trace: > 1. RuntimeException->() C:\xampp7.1\htdocs\passport\vendor\laravel\passport\src\ClientRepository.php:94 > 2. Laravel\Passport\ClientRepository->personalAccessClient() C:\xampp7.1\htdocs\passport\vendor\laravel\passport\src\PersonalAccessTokenFactory.php:71

How can I solve it?

Laravel Solutions


Solution 1 - Laravel

for me it solved by running

php artisan passport:install

because it have been happened after refreshing my database.

Solution 2 - Laravel

You have to create access clients first. It is documented here. An access client it not the same than a user token, you can have one access client and many users with different passwords and tokens.

Solution 3 - Laravel

In addition to the namelivia's comment. As Laravel doc says:

> Before your application can issue personal access tokens, you will > need to create a personal access client. You may do this using the > passport:client command with the --personal option. If you have > already run the passport:install command, you do not need to run this > command:

php artisan passport:client --personal

But if you did not run the command:

php artisan passport:install

You should run it first.

Solution 4 - Laravel

After running the command

php artisan passport:client --personal

and give you this prompt

 What should we name the personal access client? [Artisan Personal Access Client]:

don't worry just type in any name and press the enter key.

Solution 5 - Laravel

should I call

php artisan passport:install

every time I run

php artisan:migrate

there is a way to do it properly?

Solution 6 - Laravel

Simply run this command

php artisan passport:install --force

Solution 7 - Laravel

i had the same error over and over again but i didn't how to reproduce it, but i figured it out why. when you execute php artisan passport:install, it stores the two clients IDs in the database after the migrate command, but if you fresh migrate again, it's obvious you'll lose those two previous IDs, this is why this error was shown after executing the install command.

UPDATE php artisan passport:install -f will force recreating the IDs for the new migrated database.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJonioView Question on Stackoverflow
Solution 1 - LaravelRuberandinda PatienceView Answer on Stackoverflow
Solution 2 - LaravelnameliviaView Answer on Stackoverflow
Solution 3 - LaravelRuslan SkaldinView Answer on Stackoverflow
Solution 4 - Laravelstanley mboteView Answer on Stackoverflow
Solution 5 - LaravelJahStationView Answer on Stackoverflow
Solution 6 - LaravelMohammed AtallahView Answer on Stackoverflow
Solution 7 - Laraveloussama benounnasView Answer on Stackoverflow