We're adapting a laravel website into a laravel SPA, and in the future, a Mobile App that uses the web app, so we need some sort of API authentication. We're using Laravel Passport for that.
I've been using Laravel 5.5 and following the guide on the Docs, but when I try using the new login with postman, the server freezes, the HTTP requests never processing.
After some debugging, I found out that it crashes when I use Guzzle to post into the /oauth/token route. But when I use Postman to access that route, I have no problem.
This is my code:
public function login(Request $request){
$http = new Client();
var_dump(1);
//die
$response = $http->post('http://localhost:8000/oauth/token', [ //Con postman esta ruta funciona
'form_params' => [
'grant_type' => 'password',
'client_id' => env('PASSWORD-CLIENT_ID',2),
'client_secret' => env('PASSWORD-CLIENT_SECRET',2),
'username' => $request->username, //parece usar correo, no nombre de usuario
'password' => $request->password,
'scope' => '*',
],
]);
var_dump(2);
//die;
return json_decode((string) $response->getBody(), true);
}
Is this a problem with Guzzle, Or with Oauth/Passport?