Reputation: 2400
I am new Laravel Passport and i want to create a oauth_client with a user_id, now in the table oauth_clients
is the user_id null.
I want to login and get the oauth_clients credentials by user_id.
How can i create a oauth client based on a user_id
so not with php artisan passport:client --password
but with a endpoint.
I hope someone can help me how to achieve.
Upvotes: 1
Views: 1585
Reputation: 9313
You can use ClientRepository::class
.
use Laravel\Passport\ClientRepository;
(new ClientRepository)->createPersonalAccessClient($userId, $name, $redirect);
use Laravel\Passport\ClientRepository;
(new ClientRepository)->createPasswordGrantClient($userId, $name, $redirect);
Or from Passport::class
Passport::client()->forceFill([
'user_id' => $userId,
'name' => $name,
'secret' => ($confidential || $personalAccess) ? Str::random(40) : null,
'redirect' => $redirect,
'personal_access_client' => $personalAccess,
'password_client' => $password,
'revoked' => false,
]);
Upvotes: 2