Ad
Passport - Create Client Credentials Grant Client Programmatically
The documentation Here suggests php artisan passport:client --client
for creating a client, but I want to do it using a controller, or ideally, using the native JSON apis provided by passport.
Is that possible at all or will I have to override the methods in Passport::client
?
Ad
Answer
Old question, but here's a 2021 answer for people finding this on Google.
I find calling Artisan commands from code unsavory, especially as @kishore-kadiyala mentioned because you get back printed output, rather than code.
Instead, you can use the Laravel\Passport\ClientRepository class to create a client directly:
use Laravel\Passport\ClientRepository;
// ... snip ...
$clients = App::make(ClientRepository::class);
// 1st param is the user_id - none for client credentials
// 2nd param is the client name
// 3rd param is the redirect URI - none for client credentials
$client = $clients->create(null, 'My Client Name', '');
Here, $client
is a Laravel\Passport\Client instance directly. This is exactly how the Artisan command creates the clients anyway.
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad