kreait / laravel-firebase

A Laravel package for the Firebase PHP Admin SDK
https://github.com/kreait/firebase-php
MIT License
995 stars 161 forks source link

Error in a VM in google cloud #46

Closed marcoprodata closed 3 years ago

marcoprodata commented 3 years ago

Dears,

Firstly, sorry for my bad english. I have a server in google cloud platform with ubuntu, in my local machine, the project works correctly, but when deploy in a server in google cloud, have this error: "message": "Missing or insufficient permissions.", "code": 7, "status": "PERMISSION_DENIED", "details": []

How to solve this?

jeromegamez commented 3 years ago

Could you please make sure that you are using the latest version of the underlying SDK? It should be 5.6.0, a composer update should get it, and you can check with composer show | grep kreait

If you're using auto-discovery instead of a service account JSON key, please make sure that the FIREBASE_CREDENTIALS environment variables is not set.

marcoprodata commented 3 years ago

output of composer show: kreait/clock 1.0.1 A PHP 7.0 compatible clock abstraction kreait/firebase-php 5.6.0 Firebase Admin SDK kreait/firebase-tokens 1.10.0 A library to work with Firebase tokens kreait/laravel-firebase 2.2.0 A Laravel package for the Firebase PHP Admin SDK

i set the audiscover to false and put the credential file in the root folder of api, the project when running in windows machine works, but when i deploy in a gcloud vm instance return this error

jeromegamez commented 3 years ago

In that case, can you confirm that the environment variable FIREBASE_CREDENTIALS points to the correct location/path?

marcoprodata commented 3 years ago

Ok, i was open the database with the wrong way, $db = new FirestoreClient( [ 'projectId' => 'fir-xxxxxxxxxx', ] );

now i open the db like this $db = app('firebase.firestore')->database();

and this work, thanks for you support

jeromegamez commented 3 years ago

You're welcome! 🌺