Set up a new project with Laravel 5.8 and I also installed Laravel Passport & Guzzle. Created a local server with php artisan serve on port 8000. Postman is able to get a response at /oauth/token (but only when the body is in JSON).
When I try to access the API through a controller method my browser returns a 500 error and no errors are showing up in the logs. When I try to point guzzle to the same controller method through a route postman keeps loading and it's even needed to force close my php process. When I try to make a get request to the API (another route) with Guzzle it also keeps hanging in postman. If I target the route directly in postman it shows the contents. Axios also returns the contents needed.
$http = new Client();
$result = $http->post('http://localhost:8000' . '/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => config('app.api_client'),
'client_secret' => config('app.api_secret'),
'username' => $user->email,
'password' => $password,
],
]);
I also tried
$http = new Client();
$result = $http->post('/oauth/token', [
'form_params' => [
'base_uri' => config('app.url'),
'headers' => [
'Accept' => 'application/json',
],
'grant_type' => 'password',
'client_id' => config('app.api_client'),
'client_secret' => config('app.api_secret'),
'username' => $user->email,
'password' => $password,
],
]);
And I also tried the first version with the headers, and both with scope => ''
, but no luck.
Does anyone know what I'm doing wrong?