Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kenphanith's avatar

data truncated when trying to create personal access client for passport

Dear great developers, I am new to Laravel and now I am creating an application in Laravel using laravel/passport. I have an issue when trying to create a personal access client. I run php artisan passport:client --personal but I got this following error

SQLSTATE[01000]: Warning: 1265 Data truncated for column 'id' at row 1 (SQL: insert into `oauth_clients` (`user_id`, `name`, `secret`, `provider`, `redirect`, `personal_access_client`, `password_client`, `revoked`, `id`, `updated_at`, `created_at`) values (?, PAC, ed7r2VNqyV7RCW3NZXlkq145jQVe8AwMDPDNDi47, ?, http://localhost, 1, 0, 0, 913a0ac7-5e2b-4d0c-abcd-aa6eb4d52085, 2020-08-07 07:19:09, 2020-08-07 07:19:09))

I've no idea of what's going on behind. please help

0 likes
7 replies
chr15k's avatar
chr15k
Best Answer
Level 7

the id 913a0ac7-5e2b-4d0c-abcd-aa6eb4d52085 is too big for your id column so it can't store it. It also contains hyphens which won't work as I'm assuming your id column type is BIGINT?

Do you have a code example?

1 like
kenphanith's avatar

@chr15k thanks for your reply below is the migration file

$this->schema->create('oauth_clients', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->nullable()->index();
            $table->string('name');
            $table->string('secret', 100)->nullable();
            $table->string('provider')->nullable();
            $table->text('redirect');
            $table->boolean('personal_access_client');
            $table->boolean('password_client');
            $table->boolean('revoked');
            $table->timestamps();
        });

So in stead of using id(), do you think what should I use ? Sorry I am a bit confusing now

SilenceBringer's avatar

@kenphanith I recomment to keep your id as it is now (it is a good way to have primary key with auto-increment). Instead create one more column, named for example auth_id, and store you value in it

$table->string('auth_id')->unique();
1 like
kenphanith's avatar

@chr15k I changed $table->id() to $table->uuid('id')->primary(); and it works thank you very much for your answer. I appreciate it 💜

cristianeto's avatar

This thing happened to me, It's because I use this command : php artisan passport:install --uuids I wanted to use uuid for my PK at the beginning but I changed my mind.

So, To Fix it I had to edit de Passport Config file. To see the passport config file, you must publish the config file with the next command: php artisan vendor:publish --tag=passport-config

The before command generates the config/passport.php. So edit it!

client_uuids: false

Finally execute php artisan passport:install without --uuid option

It works!

2 likes

Please or to participate in this conversation.