1

I have followed the instructions for installing a password client for Laravel passport exactly as written in the Laravel docs and with default Laravel 6.0 composer versions of guzzle, etc. I have done the install on an existing project and as a clean install, both on local dev environment and live server, and every time I try to post to the example.com/oauth/token route, I am greeted with a crazy Guzzle error that seems to have no previous search history on the internet. The error is (summarized):

GuzzleHttp\Exception\ServerException

/var/task/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113

"Return value of Zend\\Diactoros\\normalizeServer() must be of the type array, none returned"

I am running php 7.3 in all environments, but tried php 7.2 and 7.1 and got the same result. I'm running Laravel Valet locally, and have never seen anything like this on any other project. I am also running a staging server with Laravel Vapor, and I get the exact same error. My guzzle request is almost exactly the same as Taylor Otwell's example in the Laravel docs, and looks like this:

        $http = new \GuzzleHttp\Client;

        $response = $http->post(env('API_TOKEN_URL'), [
            'form_params' => [
                'grant_type' => 'password',
                'client_id' => env('PASSPORT_CLIENT_ID'),
                'client_secret' => env('PASSPORT_CLIENT_SECRET'),
                'username' => $request['username'],
                'password' => $request['password'],
            ],
        ]);

        return json_decode((string) $response->getBody(), true);

I have data dumped all variables to verify that the username, password, client_id and client_secret are all accurate. It doesn't seem to be an authentication issue at all, but some issue with Guzzle passing proper server headers. I have no idea how to fix, as there is no previous record of this issue that I could find anywhere else on the internet. Any ideas???

2
  • I'm facing the same issue. I dumped all my tables including passport migration table. After that It started giving this error. Any luck from your end? Commented Jan 9, 2020 at 21:41
  • I got my environment to work again by changing passport version in composer and running a composer update, then reverting back. I found that there must have been an error in my code, because I copied a guzzle request from another project and when I ran it on the new clean install of passport, everything worked fine. I think it has more to do with being a bad error message than anything else. There’s probably a bug in the code we just didn’t see. Commented Jan 11, 2020 at 1:27

1 Answer 1

4

if someone face this issue just update the package name: laminas/laminas-diactoros to latest version such as 2.2.2 by running

composer require laminas/laminas-diactoros

the problem comes from normalize_server.legacy.php its does not return anything.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.