Hello everybody,
I would like to ask you for articles on how to consume a Laravel API (I will call this Laravel Proviider) from another external Laravel instance (I will call this Laravel Client).
The Setup
The Laravel Provider is providing the API-routes for it's own vue/vuex/vue-router based frontend. To archive this, I integrated laravel/passport.
After running php artisan passport:install on the Laravel Provider I added the generated client id and the secret to .env to consume it in my LoginController like this:
$request = Request::create('/oauth/token', 'POST', [
'grant_type' => 'password',
'client_id' => config('services.vue_client.id'),
'client_secret' => config('services.vue_client.secret'),
'username' => $request->email,
'password' => $request->password,
]);
I guess I could authenticate users on the Laravel Client this way, too.
Open question
- How do I allow the Laravel Client to access Laravel Server's API routes?
- How do I create a second passport client without overwriting the others?