New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to parse URI #228
Comments
If the project ID in your service account file doesn't match the database URI, you have to specify the database URI as documented in https://firebase-php.readthedocs.io/en/latest/setup.html#custom-database-uri : $firebase = (new Factory())
->withServiceAccount($serviceAccount)
->withDatabaseUri(...)
->create(); You can find the URI for your database by navigating to the realtime database in the Firebase Web console and copying the value displayed there - it should be something in the form of |
I don't understand. I use generated file from the google console panel. How is it possible that Google generates incorrect data for me? Problem is during parsing JSON. I have very old project, and my project_id is not understandable for your code. I have databaseUri: https://example.com:api-project-xxx.firebaseio.com and it is correct URI for google but it's not correct for this library and parse_url (PHP). The problem is in sign ":" . I changed GuzzleHttp\Psr7/Uri for
and it's work great, but it can't be. I think that not all URI for database is valid with RFC (parse_url), and it's a mistake to valid in this way
|
I see that firebase change url to database from: https://example.com:api-project-xxx.firebaseio.com/ I think that something like that must be implemented for for project_id in form: example.com:api-project-xxx |
The service account JSON file that Google generates is fine. It includes the project ID which can have any form, apperently. In most projects, the project ID is identical to the subdomain on firebaseio.com, so a project id That's why the SDK by default uses the project ID from the service account file and uses it for the database URI. In some project, the project ID is not identical to the subdomain on firebaseio.com, and that's why the If you are sure that you are using the database URI displayed at https://console.firebase.google.com/u/0/project/_/database/_/data (after clicking the link, select your project) and the displayed URI indeed is ❯ curl -I "https://example.com:api-project-xxx.firebaseio.com/"
curl: (3) Port number ended with 'a' This SDK, Guzzle and any HTTP Client need a valid URL to be able to connect to it. Even if you change Guzzle's source code, you will not be able to connect. |
This is something you can do when initializing the SDK: $firebase = (new Factory())
->withServiceAccount($serviceAccount)
->withDatabaseUri('https://example-com-api-project-xxx.firebaseio.com')
->create(); |
Yep, if I use withDatabaseUri with my URI, then it's work great. But I think, that library should do this. anyway, thanks @jeromegamez . |
I will try to look for a reliable specification by Google/Firebase - if there is one, I will 👍 |
Hello again @digitalStyx 😅 If you upgrade to the latest release, you should be able to remove the |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I use version 4.13 with PHP 7.2.5 .
I have a project name in the form
"project_id": "example.com:api-project-xxxxxx",
and when I use example
I got error
Fatal error: Uncaught InvalidArgumentException: Unable to parse URI: https://example.com:api-project-xxxxxx.firebaseio.com in /export/www/DEVEL/example.com/vendor/guzzlehttp/psr7/src/Uri.php on line 78
What can be? example.com:api-project-xxxxxx is a valid name form for google
The text was updated successfully, but these errors were encountered: