kreait / laravel-firebase

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

[question] Accessing 3rd party Firestore #136

Closed imClement closed 2 years ago

imClement commented 2 years ago

Hi,

Is it possible to access 3rd party Cloud Firestore using laravel-firebase ?

I have access to the 3rd party data through REST api without authentication just using: https://firestore.googleapis.com/v1/projects/project_name/databases/(default)/documents/collection

But when I try to access it trough laravel-firebase I get Unable to determine the Firebase Project ID

In the config file I only change the name of the project as I don't have access to create and download the json file for Service Account (it is about a 3rd party database)

    'default' => env('FIREBASE_PROJECT', 'project_name'),
    'projects' => [
        'project_name' => [

Thank you,

jeromegamez commented 2 years ago

Do I understand correctly that you want to access multiple Firebase projects with the same service account JSON? If so, you can configure multiple projects with the same Service Account JSON:

<?php
return [
    'projects' => [
        'my_project' => [
            'credentials' => [
                'file' => '/same/path/to/same_serviceaccount.json',
            ]
        ],
        '3rdparty' => [
            'credentials' => [
                'file' => '/same/path/to/same_serviceaccount.json',
            ]
        ],
    ]
];

If you don't have a service account JSON at all and the Firestore collection of the 3rd party has open access (which I've not heard of before), that's not possible with this package. In this case, you would have to try and use https://github.com/googleapis/google-cloud-php-firestore directly.

imClement commented 2 years ago

The last assumption is correct. We have access to get all documents from a collection through REST api without authentication. And wanted to use this package for fluent queries. Thank you for the suggestion.