-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
Message: No service account has been found #79
Comments
The Service Account-JSON should never be publicly accessible, please move it out of the web root, or disallow access to it. I don't know what |
Yeah, I didn't mean to leave it public, but only for debugging the problem. |
Well I am debugging this and it has nothing to do with your package. For some reason PHP not accessing the file. So I am closing this. Thanks |
Hi,
I am using this test script. <?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
require __DIR__.'/vendor/autoload.php';
use Kreait\Firebase;
$firebase = (new Firebase\Factory())
->withCredentials(__DIR__.'/Admin.json')
->create();
$database = $firebase->getDatabase();
$db->getReference('config/website')
->set([
'name' => 'My Application',
'emails' => [
'support' => 'support@domain.tld',
'sales' => 'sales@domain.tld',
],
'website' => 'https://app.domain.tld',
]);
$db->getReference('config/website/name')->set('New name'); How do I allow php to access this file? |
You have set the environment variable to |
By the way, when you set the environment variable, you don't need to use |
Sorry, I forgot to mention I have a copy of admin.json located at /firebase and my attempt to use the demo that didn't use withCredentials with my var set also failed. Any idea why? I had also set it to the path in my HTML folder and that returned the same result. |
@sfxworks I just released a new version (https://github.com/kreait/firebase-php/releases/tag/3.0.1) which should be more informative when the credentials could not be loaded. Please update to this version and try again. The message should read something like
Just to make sure it tries to access the correct file, and you can check if at least that's okay. As far as the permissions go, I'm afraid this is out of scope of this library, but I hope the new release helps to debug further. |
Same thing. I don't understand what the problem is. If there is a json file there the path is correct and it's being pointed at properly what is the problem. <?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
require __DIR__.'/vendor/autoload.php';
use Kreait\Firebase;
echo "Path = " . __DIR__.'/Admin.json';
$firebase = (new Firebase\Factory())
->withCredentials(__DIR__.'/Admin.json')
->create();
$database = $firebase->getDatabase();
$db->getReference('config/website')
->set([
'name' => 'My Application',
'emails' => [
'support' => 'support@domain.tld',
'sales' => 'sales@domain.tld',
],
'website' => 'https://app.domain.tld',
]);
$db->getReference('config/website/name')->set('New name');
?>
|
Hey,
I had this error and the following worked:
I created a folder at the webroot and put the json file in it and I declare
a local constant (string) that holds /firebase/dev.json
const AUTH_JSON = '/firebase/dev.json';
I set the rights that file and folder are not accessible from outside
so when I call withCredentials:
(new \Firebase\Factory())->withCredentials($_SERVER['DOCUMENT_ROOT'].self::AUTH_JSON)->create();
And this worked. Other ways didn't.
Greg
2017-04-28 6:48 GMT+02:00 Samuel Walker <notifications@github.com>:
… Same thing. I don't understand what the problem is. If there is a json
file there the path is correct and it's being pointed at properly what is
the problem.
<?phperror_reporting(E_ALL);ini_set('display_errors', 'on');require __DIR__.'/vendor/autoload.php';use Kreait\Firebase;echo "Path = " . __DIR__.'/Admin.json';$firebase = (new Firebase\Factory()) ->withCredentials(__DIR__.'/Admin.json') ->create();$database = $firebase->getDatabase();$db->getReference('config/website') ->set([ 'name' => 'My Application', 'emails' => [ 'support' => ***@***.***', 'sales' => ***@***.***', ], 'website' => 'https://app.domain.tld', ]);$db->getReference('config/website/name')->set('New name');?>
Path = /var/www/html/firebase/firebase-php-3.0.1/src/Admin.json
Fatal error: Uncaught Kreait\Firebase\Exception\LogicException: No service account has been found. Please set the path to a service account credentials file with Kreait\Firebase\Factory::withCredentials($path)() in /var/www/html/firebase/firebase-php-3.0.1/src/vendor/kreait/firebase-php/src/Firebase/Factory.php:99 Stack trace: #0 /var/www/html/firebase/firebase-php-3.0.1/src/vendor/kreait/firebase-php/src/Firebase/Factory.php(73): Kreait\Firebase\Factory->getServiceAccount() #1 /var/www/html/firebase/firebase-php-3.0.1/src/FirebaseTest2.php(14): Kreait\Firebase\Factory->create() #2 {main} thrown in /var/www/html/firebase/firebase-php-3.0.1/src/vendor/kreait/firebase-php/src/Firebase/Factory.php on line 99
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#79 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADuzwVaTkcMeOEnwgJihpoDCUc2VJBgtks5r0W-MgaJpZM4NAer6>
.
|
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. |
Hi,
I've installed the latest package and I am on PHP 7 and I am getting the following message:
Type: Firebase\Exception\LogicException Message: No service account has been found. Please set the path to a service account credentials file with Firebase\Factory::withCredentials($path)()
I don't quite understand why since I put the file in a folder that is in the root of the website, I can access the file from a browser.
Here is how I call it:
$this->firebase = (new \Firebase\Factory())->withCredentials(self::AUTH_JSON)->create();
Any idea how could I debug this?
Thanks very much.
Greg
The text was updated successfully, but these errors were encountered: