kreait / firebase-tokens-php

A PHP library to work with Firebase tokens
MIT License
223 stars 33 forks source link

Token future time error #13

Closed navee85 closed 5 years ago

navee85 commented 5 years ago

I am trying to verify the firebase token but sometimes, it is throwing token issued at future timestamp error, as in the following exception:

This token has been issued in the future at 2019-06-07T08:43:57+00:00, is your system time correct? {"exception":"[object] (Firebase\\Auth\\Token\\Exception\\IssuedInTheFuture(code: 0): This token has been issued in the future at 2019-06-07T08:43:57+00:00, is your system time correct? at /var/www/html/vendor/kreait/firebase-tokens/src/Verifier.php:95)

I debugged the the code, and I saw the following rows are the problem:

    private function verifyAuthTime(Token $token)
    {
       ...
        if ($token->getClaim('auth_time') > time()) {
            throw new InvalidToken($token, "The user's authentication time must be in the past");
        }
    }

The difference is between the auth_time and time() only a few seconds.

jeromegamez commented 5 years ago

Thanks for bringing this up! I've known the problem for quite some time now, and I think it's time that I address it. I'll work on this soon!

jeromegamez commented 5 years ago

Implemented #14 with 7e9877a0187e88c3d96372e2d06cdecc6db87254

diego-lipinski-de-castro commented 3 years ago

Hello, I have this problem now, could this be someting related to the server time?

jeromegamez commented 3 years ago

That's the likely cause, yes! You can verify a token with leeway to give the verification more "room": https://github.com/kreait/firebase-tokens-php#verify-an-id-token

diego-lipinski-de-castro commented 3 years ago

Yeah, I fixed it, server time was 20 minutes in the past, thanks for the return tho

mahmoud7796 commented 1 year ago

i'm still getting wired error when test token in postman it works fine but when it is sent from client side angular it return this error:

The value 'eyJhbGciOiJSUzI...' is not a verified ID token:\n- - The token was issued in the future\n

my code :

 $auth = app('firebase.auth');
        try {
            return $auth->verifyIdToken($this->verifierId);
        } catch (FailedToVerifyToken $e) {
            throw new InvalidTokenException($e->getMessage(),$e->getCode());
        }

any solution plz