kreait / firebase-tokens-php

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

Fatal error: Uncaught Error: Class 'IdTokenVerifier' not found in ... #36

Closed bag7dad closed 3 years ago

bag7dad commented 3 years ago

Fatal error: Uncaught Error: Class 'IdTokenVerifier' not found in public_html/session.php:18 Stack trace: #0 {main} thrown in

used composer require kreait/firebase-tokens for install it

and using your example

<?php

use Kreait\Firebase\JWT\Error\IdTokenVerificationFailed;
use Kreait\Firebase\JWT\IdTokenVerifier;

$projectId = '...';
$idToken = 'eyJhb...'; // An ID token given to your backend by a Client application

$verifier = IdTokenVerifier::createWithProjectId($projectId);

try {
    $token = $verifier->verifyIdToken($idToken);
} catch (IdTokenVerificationFailed $e) {
    echo $e->getMessage();
    // Example Output:
    // The value 'eyJhb...' is not a verified ID token:
    // - The token is expired.
    exit;
}

try {
    $token = $verifier->verifyIdTokenWithLeeway($idToken, $leewayInSeconds = 10000000);
} catch (IdTokenVerificationFailed $e) {
    print $e->getMessage();
    exit;
}
jeromegamez commented 3 years ago

If you do a composer show kreait/firebase-tokens, which version does it show?

grafik
bag7dad commented 3 years ago
 name     : kreait/firebase-tokens
descrip. : A library to work with Firebase tokens
keywords : Authentication, auth, firebase, google, token
versions : * 1.0.0
type     : library
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage : https://github.com/kreait/firebase-token-php
source   : [git] https://github.com/kreait/firebase-tokens-php.git 052d9dedd360bb161eb471ecfbb2237a1d566d91
dist     : [zip] https://api.github.com/repos/kreait/firebase-tokens-php/zipball/052d9dedd360bb161eb471ecfbb2237a1d566d91 052d9dedd360bb161eb471ecfbb2237a1d566d91
path     : D:\Web\wamp64\www\web\vendor\kreait\firebase-tokens
names    : kreait/firebase-tokens

support
issues : https://github.com/kreait/firebase-tokens-php/issues
source : https://github.com/kreait/firebase-tokens-php/tree/1.0.0

autoload
psr-4
Firebase\Auth\Token\ => src

requires
lcobucci/jwt ^3.2

requires (dev)
friendsofphp/php-cs-fixer ^2.0
jeromegamez commented 3 years ago

You have the oldest release of the library possible 😅. If you installed that version on purpose, you can find its usage in the README of https://github.com/kreait/firebase-tokens-php/tree/1.0.0

Otherwise, check the composer.json file in your project and require a newer version, e.g. ^1.15 to make sure that you receive future updates of the 1.x branch as well. 🤞

bag7dad commented 3 years ago

thank you i just forced it to use the latest version composer require kreait/firebase-tokens:1.15.0 --ignore-platform-reqs