2017-04-15 2 views

Antwort

2

antwortete ich es auf meinem eigenen, und fügte hinzu config to guzzle 'http_errors' => false gibt den Fehler an json zurück.

public function loginapi(Request $request) 
{ 
    $username = $request->username; 
    $password = $request->password; 
    $http = new Client; 

    $response = $http->post('http://restapi.dev/oauth/token', [ 
     'form_params' => [ 
      'grant_type' => 'password', 
      'client_id' => 3, 
      'client_secret' => 'Lh66IODOP4pZHF676xZA8ghQiIt9OepqYHVzFEIN', 
      'username' => $username, 
      'password' => $password, 
      'scope' => '', 
     ], 
     'http_errors' => false //add this to return errors in json 
    ]); 
     return json_decode((string) $response->getBody(), true); 
}