anyone?
Is it possible to call Laravel Passport Controller methods without using GuzzleHttp or Proxy in general?
Hi,
I just started learning Laravel and am having a tough time handling authentication. I am building a web app with Vue as front-end. Somehow I managed to solve the basic authentication issues. But now I want to send User details and OAuth2 tokens when the user login. So my login controller class has this method to send out response
protected function authenticated(Request $request, $user)
{
$http = new \GuzzleHttp\Client([
'base_uri' => config('app.url'),
'timeout' => 10,
]);
$response = $http->post('/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => '123',
'client_secret' => 'P*************************************************E',
'username' => $request->input('email'),
'password' => $request->input('password'),
'scope' => '',
],
]);
//TODO return array_merge of $user values and $response->getBody()
// Now I am just sending out true to avoid page redirects as all my forms
// are submitted through AJAX
return true;
}
How can I merge the two responses together and send out response as JSON? The $user param is of type \Illuminate\Contracts\Auth\Authenticatable.
Moreover GuzzleHttp client seems to be very slow, so I'd like to remove this and directly access the '/oauth/token' controller methods. Is this possible? Or is there any other better ways to handle this situation.
Please or to participate in this conversation.