拉拉维尔护照:客户端 --个人'access_token_id'没有默认值



我已经安装了Laravel Passport(带有php artisan passport:install --uuids)并尝试生成PAT。在执行此操作之前,必须创建个人客户端。

每当我跑步时:

php artisan passport:client --personal

将为我的数据库创建一个新客户端,但我收到以下错误:

IlluminateDatabaseQueryException 
SQLSTATE[HY000]: General error: 1364 Field 'access_token_id' doesn't have a default value (SQL: insert into `oauth_refresh_tokens` (`client_id`) values (96cf1614-fe2e-42fa-83ba-ac804943c84b))
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:759
755▕         // If an exception occurs when attempting to run a query, we'll format the error
756▕         // message to include the bindings with SQL, which will make this exception a
757▕         // lot more helpful to the developer instead of just the database's errors.
758▕         catch (Exception $e) {
➜ 759▕             throw new QueryException(
760▕                 $query, $this->prepareBindings($bindings), $e
761▕             );
762▕         }
763▕     }
+28 vendor frames 
29  artisan:37
IlluminateFoundationConsoleKernel::handle()

我可以通过nullable归咎字段来解决这个问题,我只是想知道是否有其他人对护照的 PAT 有同样的问题。

这是原始迁移:

public function up()                                                           
{                                                                              
$this->schema->create('oauth_refresh_tokens', function (Blueprint $table) {
$table->string('id', 100)->primary();                                  
$table->string('access_token_id', 100)->index();                       
$table->boolean('revoked');                                            
$table->dateTime('expires_at')->nullable();                            
});                                                                        
}                                                                              

需要此更新才能使其正常工作:

public function up()
{
$this->schema->create('oauth_refresh_tokens', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('client_id')->nullable()->index();
$table->uuid('access_token_id')->nullable()->index();
$table->boolean('revoked')->nullable();
$table->dateTime('expires_at')->nullable();
});
}

更新

实施上述解决方法后,我运行

php artisan passport:client --personal --user_id=11111111-1111-1111-1111-111111111111 --name=PAT

..但user_idoauth_clients_table中也没有关联:

已撤销<样式="文本对齐:左;">created_at<样式="文本对齐:左;">updated_at<td style="文本对齐:左;">NULL"文本对齐:左;">NULL
iduser_idnamesecretproviderredirectpersonal_access_clientpassword_client
96cf9c98-97fa-494d-8f13-01a5856dbe3bPAT$2y$...
http://localhost1002022-07-18 22:44:56.02022-07-18 22:44:56.0

刷新数据库,然后使用此命令

php artisan passport:install

我有同样的问题,这救了我!

相关内容

最新更新