firebase-bundle: Service Account credentials file not readable or invalid

The problem

When I calling $this->container->get(‘firebase’), I get :

Capture d’écran 2019-05-07 à 17 08 37

Environment

  • Symfony flex v4.2.8
  • PHP Version : 7.2.15
  • Firebase PHP SDK and Bundle version :
  • kreait/firebase-bundle 1.2.0
  • kreait/firebase-php 4.20.1
  • kreait/firebase-tokens 1.7.2
  • kreait/gcp-metadata 1.0.1

Code to reproduce issue

My config file :

// %kernel.project_dir%/config/firebase/firebase.yaml
kreait_firebase:
    projects:
        default:
            public: true
            default: true
            credentials: '%kernel.project_dir%/config/packages/firebase/service_account_key.json'
            database_uri: 'https://myproject.firebaseio.com/'
            alias: 'firebase'

My Service Account credentials file :

// %kernel.project_dir%/config/firebase/service_account_key.json
{
  "type": "service_account",
  "project_id": "............",
  "private_key_id": "...........",
  "private_key": "...........",
  "client_email": "...........",
  "client_id": "...........",
  "auth_uri": "...........",
  "token_uri": "...........",
  "auth_provider_x509_cert_url": "...........",
  "client_x509_cert_url": "..........."
}

Thk’s

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 23 (10 by maintainers)

Most upvoted comments

In the meantime, if possible, please set the environment variable FIREBASE_CREDENTIALS to the path of the credentials file in your project, then the autodiscovery of the Firebase SDK should pick it up.

I’ll rewrite the bundle from scratch for Symfony ^3.4 and ^4.2 (those two are officially supported) and create a new major release once it’s ready (and a PR so that you can test it beforehand)

Thank you for your quickly answer !

Yes, using different service accounts could have been the reason, but I don’t think… Indeed, as I have said, I’ve tried to use cURL requests in order to make sure that this error comes from your bundle or not. Using this (bad) solution, it’s not necessary to put a service_account.json file (cURL request requires only the FCM server key).

Indeed, maybe there is a delay before Google accepts Apple APN auth key, I don’t know… For sure, using APN auth key is supposed to ease all that configuration. You have to just to create a key from your apple account developer and download it. Then, you have to import this key into your firebase cloud messaging part and fill in some fields (team id, bundle id, etc.), just it.

I have to work about this issue tomorrow, I keep you informed ! Thank you for your support @jeromegamez 😁

@kylenoland @JordanProtin Could you please update to release 1.3 of the bundle and see if and how the behaviour changes? The new release includes changes in the SDK and in the configuration handling:

  • The handling of environment variables has been improved when using autodiscovery (this seems to be an issue especially on Windows machines (thanks again @Shifu33 for your help in the kreait Discord)
  • Credential autodiscovery is now disabled when the credentials configuration option has been set. This prevents triggering it when there is a problem with the configured credentials.

This should help at least narrowing down the issue a little, if it doesn’t fix it 🤞- please let me know what you find out!