kreait / firebase-php

Unofficial Firebase Admin SDK for PHP
https://firebase-php.readthedocs.io/
MIT License
2.26k stars 429 forks source link

guzzlehttp/guzzle/src/Exception/RequestException.php at function verifyPassword() #372

Closed LeMajstor closed 4 years ago

LeMajstor commented 4 years ago

By calling the verifyPassword() function in Lumen framework i got the following error:

GuzzleHttp\\Exception\\ClientException(code: 400): Client error: POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword resulted in a 400 Bad Request response

All the others methods shown in documentation work fine, I only have problem with this one.

Here's my code

public function __construct() {
        $serviceAccount = "{{ my_path }}";
        $factory = (new Factory)
            ->withServiceAccount($serviceAccount)
            ->withDatabaseUri('{{ my_url }}');
        $this->database = $factory->createDatabase();
        $this->auth = $factory->createAuth();
    }

verifyPassword function call

       public function login (Request $request) {

        $data = $request->header('Authorization');
        $email = $_SERVER['PHP_AUTH_USER'];
        $pwd = $_SERVER['PHP_AUTH_PW'];

        if ((isset($email) && !empty($email)) && (isset($pwd) && !empty($pwd))) {
            $user = $this->auth->verifyPassword($email, $pwd);
        }
    }
jeromegamez commented 4 years ago

Are you using https://github.com/kreait/laravel-firebase? With that, you don't have to create factory instances yourself.

You could debug this further with something like this:

try {
    $user = $this->auth->verifyPassword('jerome@gamez.name', 'wrongpassword');
} catch (Throwable $e) {
    echo get_class($e).': '.$e->getMessage();
    exit;
}

What intrigues me is that a Guzzle ClientException should not be thrown directly in any case, but wrapped/converted into an SDK specific exception.

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.