firebase-php: Application default credentials don't work

Hi,

I was looking around the service account discovery file and i saw these methods were used to discover them:

    public function getDefaultMethods(): array
    {
        return [
            new Discovery\FromEnvironmentVariable('FIREBASE_CREDENTIALS'),
            new Discovery\FromEnvironmentVariable(CredentialsLoader::ENV_VAR),
            new Discovery\FromGoogleWellKnownFile(),
            new Discovery\OnGoogleCloudPlatform(),
        ];
    }

The FromGoogleWellKnownFile one seems to imply that it will look for the application default credentials in $HOME/.config/gcloud/application_default_credentials.json. That file exists on my system. However if i don’t set GOOGLE_APPLICATION_CREDENTIALS php errors out with

Kreait\\Firebase\\ServiceAccount\\Discovery\\FromEnvironmentVariable: The environment variable \"FIREBASE_CREDENTIALS\" is not set.\nKreait\\Firebase\\ServiceAccount\\Discovery\\FromEnvironmentVariable: The environment variable \"GOOGLE_APPLICATION_CREDENTIALS\" is not set.\nThe following fields are missing/empty in the Service Account specification: \"project_id\", \"client_email\", \"private_key\". Please make sure you download the Service Account JSON file from the Service Accounts tab in the Firebase Console, as shown in the documentation on https://firebase.google.com/docs/admin/setup#add_firebase_to_your_app\ncURL error 28: Connection timed out after 1001 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)",

Can you fix it so that the application default credentials get picked up properly?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

I do appreciate the effort btw!