kreait / firebase-php

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

Validate Registration Tokens returns no result #937

Closed Rigsto closed 6 days ago

Rigsto commented 6 days ago

Describe the bug

I need to validate all my registration tokens in the database, so I use the validateRegistrationTokens method to use it, but it gave me an empty results.

Is this a bug, or have I implemented the code wrong?

Installed packages

barryvdh/laravel-ide-helper          2.15.1   Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.
barryvdh/reflection-docblock         2.1.1   
beste/clock                          3.0.0    A collection of Clock implementations
beste/json                           1.5.0    A simple JSON helper to decode and encode JSON
brick/math                           0.11.0   Arbitrary-precision arithmetic library
carbonphp/carbon-doctrine-types      2.1.0    Types to use Carbon in Doctrine
clue/stream-filter                   1.7.0    A simple and modern approach to stream filtering in PHP
composer/class-map-generator         1.3.4    Utilities to scan PHP code and generate class maps.
composer/pcre                        3.3.1    PCRE wrapping library that offers type-safe preg_* replacements.
defuse/php-encryption                2.4.0    Secure PHP Encryption Library
dflydev/dot-access-data              3.0.3    Given a deep data structure, access data by dot notation.
doctrine/cache                       2.2.0    PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.
doctrine/dbal                        3.9.1    Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations                1.1.3    A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.
doctrine/event-manager               2.0.1    The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                   2.0.10   PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.
doctrine/instantiator                2.0.0    A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                       2.1.1    PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
dragonmantank/cron-expression        3.3.3    CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
egulias/email-validator              3.2.6    A library for validating emails against several RFCs
fakerphp/faker                       1.23.1   Faker is a PHP library that generates fake data for you.
fig/http-message-util                1.1.5    Utility classes and constants for use with PSR-7 (psr/http-message)
filp/whoops                          2.15.4   php error handling for cool kids
firebase/php-jwt                     6.10.1   A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.
flynsarmy/csv-seeder                 2.0.6    Allows seeding of the database with CSV files
fruitcake/php-cors                   1.3.0    Cross-origin resource sharing library for the Symfony HttpFoundation
google/auth                          1.42.0   Google Auth Library for PHP
google/cloud-core                    1.59.1   Google Cloud PHP shared dependency, providing functionality useful to all components.
google/cloud-storage                 1.42.1   Cloud Storage Client for PHP
google/common-protos                 4.8.3    Google API Common Protos for PHP
google/gax                           1.34.1   Google API Core for PHP
google/grpc-gcp                      0.4.0    gRPC GCP library for channel management
google/longrunning                   0.4.3    Google LongRunning Client for PHP
google/protobuf                      4.28.2   proto library for PHP
graham-campbell/result-type          1.1.3    An Implementation Of The Result Type
grpc/grpc                            1.57.0   gRPC library for PHP
guzzlehttp/guzzle                    7.9.2    Guzzle is a PHP HTTP client library
guzzlehttp/promises                  2.0.3    Guzzle promises library
guzzlehttp/psr7                      2.7.0    PSR-7 message implementation that also provides common utility methods
guzzlehttp/uri-template              1.0.3    A polyfill class for uri_template of PHP
hamcrest/hamcrest-php                2.0.1    This is the PHP port of Hamcrest Matchers
http-interop/http-factory-guzzle     1.2.0    An HTTP Factory using Guzzle PSR7
intervention/image                   2.7.2    Image handling and manipulation library with support for Laravel integration
jean85/pretty-package-versions       2.0.6    A library to get pretty versions strings of installed dependencies
kreait/firebase-php                  7.0.0    Firebase Admin SDK
kreait/firebase-tokens               4.3.0    A library to work with Firebase tokens
laravel-validation-rules/credit-card 1.9.0    Validate credit card number, expiration date, cvc
laravel/framework                    9.52.16  The Laravel Framework.
laravel/passport                     10.4.2   Laravel Passport provides OAuth2 server support to Laravel.
laravel/sail                         1.32.0   Docker files for running a basic Laravel application.
laravel/sanctum                      2.15.1   Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.
laravel/serializable-closure         1.3.4    Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.
laravel/tinker                       2.9.0    Powerful REPL for the Laravel framework.
laravel/ui                           3.4.6    Laravel UI utilities and presets.
lcobucci/clock                       3.0.0    Yet another clock abstraction
lcobucci/jwt                         4.3.0    A simple library to work with JSON Web Token and JSON Web Signature
league/commonmark                    2.5.3    Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)
league/config                        1.2.0    Define configuration arrays with strict schemas and access values with dot notation
league/event                         2.2.0    Event package
league/flysystem                     3.28.0   File storage abstraction for PHP
league/flysystem-local               3.28.0   Local filesystem adapter for Flysystem.
league/mime-type-detection           1.16.0   Mime-type detection for Flysystem
league/oauth2-server                 8.5.4    A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your A...   
league/uri                           7.4.1    URI manipulation library
league/uri-interfaces                7.4.1    Common interfaces and classes for URI representation and interaction
midtrans/midtrans-php                2.5.2    PHP Wrapper for Midtrans Payment API.
mockery/mockery                      1.6.12   Mockery is a simple yet flexible PHP mock object framework
monolog/monolog                      2.9.3    Sends your logs to files, sockets, inboxes, databases and various web services
mtdowling/jmespath.php               2.8.0    Declaratively specify how to extract elements from a JSON document
myclabs/deep-copy                    1.12.0   Create deep copies (clones) of your objects
nesbot/carbon                        2.72.5   An API extension for DateTime that supports 281 different languages.
nette/schema                         1.3.0    📐 Nette Schema: validating data structures against a given Schema.
nette/utils                          4.0.5    🛠  Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
nikic/php-parser                     5.2.0    A PHP parser written in PHP
nunomaduro/collision                 6.4.0    Cli error handling for console/command-line PHP applications.
nunomaduro/termwind                  1.15.1   Its like Tailwind CSS, but for the console.
nyholm/psr7                          1.8.2    A fast PHP7 implementation of PSR-7
paragonie/constant_time_encoding     3.0.0    Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)
paragonie/random_compat              9.99.100 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phar-io/manifest                     2.0.4    Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                      3.2.1    Library for handling version information and constraints
php-http/client-common               2.7.1    Common HTTP Client implementations and tools for HTTPlug
php-http/discovery                   1.19.4   Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations
php-http/httplug                     2.4.0    HTTPlug, the HTTP client abstraction for PHP
php-http/message                     1.16.1   HTTP Message related tools
php-http/message-factory             1.1.0    Factory interfaces for PSR-7 HTTP Message
php-http/promise                     1.3.1    Promise used for asynchronous HTTP requests
phpdocumentor/reflection-common      2.2.0    Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/type-resolver          1.8.2    A PSR-5 based resolver of Class names, Types and Structural Element Names
phpoption/phpoption                  1.9.3    Option Type for PHP
phpseclib/phpseclib                  3.0.42   PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.
phpstan/phpdoc-parser                1.30.1   PHPDoc parser with support for nullable, intersection and generic types
phpunit/php-code-coverage            9.2.32   Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator            3.0.6    FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                  3.1.1    Invoke callables with a timeout
phpunit/php-text-template            2.0.4    Simple template engine.
phpunit/php-timer                    5.0.3    Utility class for timing
phpunit/phpunit                      9.6.21   The PHP Unit Testing framework.
psr/cache                            3.0.0    Common interface for caching libraries
psr/clock                            1.0.0    Common interface for reading the clock.
psr/container                        2.0.2    Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher                 1.0.0    Standard interfaces for event handling.
psr/http-client                      1.0.3    Common interface for HTTP clients
psr/http-factory                     1.1.0    PSR-17: Common interfaces for PSR-7 HTTP message factories
psr/http-message                     1.1      Common interface for HTTP messages
psr/log                              3.0.2    Common interface for logging libraries
psr/simple-cache                     3.0.0    Common interfaces for simple caching
psy/psysh                            0.12.4   An interactive shell for modern PHP.
ralouphie/getallheaders              3.0.3    A polyfill for getallheaders.
ramsey/collection                    2.0.0    A PHP library for representing and manipulating collections.
ramsey/uuid                          4.7.6    A PHP library for generating and working with universally unique identifiers (UUIDs).
rigsto/api-http-status               1.4      HTTP status codes and resources for API usages
riverline/multipart-parser           2.1.2    One class library to parse multipart content with encoding and charset support.
rize/uri-template                    0.3.8    PHP URI Template (RFC 6570) supports both expansion & extraction
sebastian/cli-parser                 1.0.2    Library for parsing CLI options
sebastian/code-unit                  1.0.8    Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup   2.0.3    Looks up which function or method a line of code belongs to
sebastian/comparator                 4.0.8    Provides the functionality to compare PHP values for equality
sebastian/complexity                 2.0.3    Library for calculating the complexity of PHP code units
sebastian/diff                       4.0.6    Diff implementation
sebastian/environment                5.1.5    Provides functionality to handle HHVM/PHP environments
sebastian/exporter                   4.0.6    Provides the functionality to export PHP variables for visualization
sebastian/global-state               5.0.7    Snapshotting of global state
sebastian/lines-of-code              1.0.4    Library for counting the lines of code in PHP source code
sebastian/object-enumerator          4.0.4    Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector           2.0.4    Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context          4.0.5    Provides functionality to recursively process PHP variables
sebastian/resource-operations        3.0.4    Provides a list of PHP built-in functions that operate on resources
sebastian/type                       3.2.1    Collection of value objects that represent the types of the PHP type system
sebastian/version                    3.0.2    Library that helps with managing the version number of Git-hosted PHP projects
sentry/sdk                           3.6.0    This is a metapackage shipping sentry/sentry with a recommended HTTP client.
sentry/sentry                        3.22.1   A PHP SDK for Sentry (http://sentry.io)
sentry/sentry-laravel                2.14.2   Laravel SDK for Sentry (https://sentry.io)
spatie/backtrace                     1.6.2    A better backtrace
spatie/flare-client-php              1.8.0    Send PHP errors to Flare
spatie/ignition                      1.14.2   A beautiful error page for PHP applications.
spatie/laravel-ignition              1.7.0    A beautiful error page for Laravel applications.
symfony/console                      6.4.12   Eases the creation of beautiful and testable command line interfaces
symfony/css-selector                 6.4.8    Converts CSS selectors to XPath expressions
symfony/deprecation-contracts        3.5.0    A generic function and convention to trigger deprecation notices
symfony/error-handler                6.4.10   Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher             6.4.8    Provides tools that allow your application components to communicate with each other by dispatching events and listening to them
symfony/event-dispatcher-contracts   3.5.0    Generic abstractions related to dispatching event
symfony/finder                       6.4.11   Finds files and directories via an intuitive fluent interface
symfony/http-client                  6.4.12   Provides powerful methods to fetch HTTP resources synchronously or asynchronously
symfony/http-client-contracts        3.5.0    Generic abstractions related to HTTP clients
symfony/http-foundation              6.4.12   Defines an object-oriented layer for the HTTP specification
symfony/http-kernel                  6.4.12   Provides a structured process for converting a Request into a Response
symfony/mailer                       6.4.12   Helps sending emails
symfony/mailgun-mailer               6.4.10   Symfony Mailgun Mailer Bridge
symfony/mime                         6.4.12   Allows manipulating MIME messages
symfony/options-resolver             6.4.8    Provides an improved replacement for the array_replace PHP function
symfony/polyfill-ctype               1.31.0   Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme       1.31.0   Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-idn            1.31.0   Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer     1.31.0   Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring            1.31.0   Symfony polyfill for the Mbstring extension
symfony/polyfill-php80               1.31.0   Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php83               1.31.0   Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions
symfony/polyfill-uuid                1.31.0   Symfony polyfill for uuid functions
symfony/process                      6.4.12   Executes commands in sub-processes
symfony/psr-http-message-bridge      2.3.1    PSR HTTP message bridge
symfony/routing                      6.4.12   Maps an HTTP request to a set of configuration variables
symfony/string                       6.4.12   Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way
symfony/translation                  6.4.12   Provides tools to internationalize your application
symfony/translation-contracts        3.5.0    Generic abstractions related to translation
symfony/uid                          6.4.12   Provides an object-oriented API to generate and represent UIDs
symfony/var-dumper                   6.4.11   Provides mechanisms for walking through any arbitrary PHP variable
symfony/yaml                         6.4.12   Loads and dumps YAML files
theseer/tokenizer                    1.2.3    A small library for converting tokenized PHP source code into XML and potentially other formats
tijsverkoyen/css-to-inline-styles    2.2.7    CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.
vlucas/phpdotenv                     5.6.1    Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
voku/portable-ascii                  2.0.1    Portable ASCII library - performance optimized (ascii) string functions for php.
webmozart/assert                     1.11.0   Assertions to validate method input/output with nice error messages.

PHP version and extensions

composer               2.7.7    Composer package
composer-plugin-api    2.6.0    The Composer Plugin API
composer-runtime-api   2.2.2    The Composer Runtime API
ext-bcmath             8.2.12   The bcmath PHP extension
ext-bz2                8.2.12   The bz2 PHP extension
ext-calendar           8.2.12   The calendar PHP extension
ext-ctype              8.2.12   The ctype PHP extension
ext-curl               8.2.12   The curl PHP extension
ext-date               8.2.12   The date PHP extension
ext-dom                20031129 The dom PHP extension
ext-exif               8.2.12   The exif PHP extension
ext-fileinfo           8.2.12   The fileinfo PHP extension
ext-filter             8.2.12   The filter PHP extension
ext-ftp                8.2.12   The ftp PHP extension
ext-gd                 8.2.12   The gd PHP extension
ext-gettext            8.2.12   The gettext PHP extension
ext-hash               8.2.12   The hash PHP extension
ext-iconv              8.2.12   The iconv PHP extension
ext-intl               8.2.12   The intl PHP extension
ext-json               8.2.12   The json PHP extension
ext-libxml             8.2.12   The libxml PHP extension
ext-mbstring           8.2.12   The mbstring PHP extension
ext-mysqli             8.2.12   The mysqli PHP extension
ext-mysqlnd            0        The mysqlnd PHP extension (actual version: mysqlnd 8.2.12)
ext-openssl            8.2.12   The openssl PHP extension
ext-pcre               8.2.12   The pcre PHP extension
ext-pdo                8.2.12   The PDO PHP extension
ext-pdo_mysql          8.2.12   The pdo_mysql PHP extension
ext-pdo_sqlite         8.2.12   The pdo_sqlite PHP extension
ext-phar               8.2.12   The Phar PHP extension
ext-random             8.2.12   The random PHP extension
ext-readline           8.2.12   The readline PHP extension
ext-reflection         8.2.12   The Reflection PHP extension
ext-session            8.2.12   The session PHP extension
ext-simplexml          8.2.12   The SimpleXML PHP extension
ext-sockets            8.2.12   The sockets PHP extension
ext-sodium             8.2.12   The sodium PHP extension
ext-spl                8.2.12   The SPL PHP extension
ext-sqlite3            8.2.12   The sqlite3 PHP extension
ext-tokenizer          8.2.12   The tokenizer PHP extension
ext-xml                8.2.12   The xml PHP extension
ext-xmlreader          8.2.12   The xmlreader PHP extension
ext-xmlwriter          8.2.12   The xmlwriter PHP extension
ext-zip                1.21.1   The zip PHP extension
ext-zlib               8.2.12   The zlib PHP extension
lib-bz2                1.0.8    The bz2 library
lib-curl               8.4.0    The curl library
lib-curl-libssh2       1.10.0   curl libssh2 version
lib-curl-openssl       3.0.11   curl OpenSSL version (3.0.11)
lib-curl-zlib          1.2.12   curl zlib version
lib-date-timelib       2022.09  date timelib version
lib-date-zoneinfo      2023.3   zoneinfo ("Olson") database for date
lib-fileinfo-libmagic  540      fileinfo libmagic version
lib-gd                 2.0.35   The gd library
lib-gd-freetype        2.11.1   freetype version for gd
lib-gd-libjpeg         8.0      libjpeg version for gd
lib-gd-libpng          1.6.34   libpng version for gd
lib-gd-libxpm          3.5.12   libxpm version for gd
lib-iconv              1.16     The iconv library
lib-icu                71.1     The ICU unicode and globalization support library
lib-icu-cldr           41       ICU CLDR project version
lib-icu-unicode        14.0.0   ICU unicode version
lib-icu-zoneinfo       2022.1   zoneinfo ("Olson") database for icu
lib-libsodium          1.0.18   The libsodium library
lib-libxml             2.10.3   libxml library version
lib-mbstring-libmbfl   1.3.2    mbstring libmbfl version
lib-mbstring-oniguruma 6.9.8    mbstring oniguruma version
lib-openssl            3.0.11   OpenSSL 3.0.11 19 Sep 2023
lib-pcre               10.40    The pcre library
lib-pcre-unicode       14.0.0   PCRE Unicode version support
lib-pdo_sqlite-sqlite  3.39.2   The pdo_sqlite-sqlite library
lib-sqlite3-sqlite     3.39.2   The sqlite3-sqlite library
lib-zip-libzip         1.7.1    The zip-libzip library
lib-zlib               1.2.12   The zlib library
php                    8.1.14   Package overridden via config.platform, actual: 8.2.12
php-64bit              8.1.14   Package overridden via config.platform, actual: 8.2.12
php-ipv6               8.1.14   Package overridden via config.platform, actual: 8.2.12
php-zts                8.1.14   Package overridden via config.platform, actual: 8.2.12

Steps to reproduce the issue.

I have an array of tokens image

Then, I tried to put the array into the code

$arr = [...];
$messaging = (new Factory())->withServiceAccount('')->createMessaging();

$result = $messaging->validateRegistrationTokens($tokens);
dd($result);

From the debugging, I code an empty array. image

Error message/Stack trace

['valid' => [], 'unknown' => [], 'invalid' => []]

Additional information

No response

jeromegamez commented 6 days ago

You have version 7.0.0 of the SDK installed, please update to the latest version and keeps dependencies updated.

Firebase has shut down the Legacy FCM API, so, outdated SDK versions still using them will not work anymore.

jeromegamez commented 6 days ago

I noticed you're using Laravel. The SDK has a package for Laravel: https://github.com/kreait/laravel-firebase