2
Wenn das Passwort Erteilung erfolgreich kehrt Format in json aber wenn Fehler zurückgibt ein HTML-Format Exception in Laravel Wie zurückzukehren Fehler in Laravel Passport Guzzle mit im JSON-Format
Wenn das Passwort Erteilung erfolgreich kehrt Format in json aber wenn Fehler zurückgibt ein HTML-Format Exception in Laravel Wie zurückzukehren Fehler in Laravel Passport Guzzle mit im JSON-Format
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);
}