Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.4 - Installing Passport

I'm trying to install passport on my Laravel 5.4 project with the help of the Laravel Documentation. But when i'm at this stage :

php artisan passport:install

I have this error :

[Illuminate\Database\QueryException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'lpo.oauth_clients' doesn't exist (SQL: insert into `oa
  uth_clients` (`user_id`, `name`, `secret`, `redirect`, `personal_access_client`, `password_client`, `revoked`, `upd
  ated_at`, `created_at`) values (, Laravel Personal Access Client, ruEzLmQYSK5RhfzSximBKoupaXaMcRSR4CvXET0o, http://
  localhost, 1, 0, 0, 2017-07-06 08:26:25, 2017-07-06 08:26:25))



  [PDOException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'lpo.oauth_clients' doesn't exist

And i should have something like this if it succeed :

Encryption keys generated successfully.
Personal access client created successfully.
Client ID: 1
Client Secret: OUA4IhQj1t3kDRuWZ6N7DQb9h1N3ccXpQw9HS2iz
Password grant client created successfully.
Client ID: 2
Client Secret: oGhkm0EPSjqxJBMkaWNZ6lIuuZoby4ev787yW6cO

I did php artisan migrate before and i had 2 new table : users and migrations.

Thanks for your help

like image 601
TuxxyDOS Avatar asked Jul 06 '17 09:07

TuxxyDOS


2 Answers

Most likely you skipped one or two of the following steps:

Next, register the Passport service provider in the providers array of your config/app.php configuration file:

Laravel\Passport\PassportServiceProvider::class,

The Passport service provider registers its own database migration directory with the framework, so you should migrate your database after registering the provider. The Passport migrations will create the tables your application needs to store clients and access tokens:

php artisan migrate

Only after that can you run

php artisan passport:install
like image 172
Luceos Avatar answered Sep 21 '22 09:09

Luceos


Laravel 5.4 provides larger default string length which can not be allowed.

Solution :

Modify AppServiceProvider.php file:

use Illuminate\Support\Facades\Schema;

Add the following line to the boot method:

public function boot(){
    Schema::defaultStringLength(150);
}
like image 44
N. Patel Avatar answered Sep 20 '22 09:09

N. Patel