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

Use Credentials from .env and not from json #63

Closed jansgescheit closed 3 years ago

jansgescheit commented 3 years ago

Is it possible to get the firebase service credentials not from a json file but from an environment or as Firebase offers as a server auth token?

Like here https://github.com/laravel-notification-channels/fcm/tree/v1#setting-up-the-fcm-service

My problem ist that i can easily set environment in my deployment but not a file.

jeromegamez commented 3 years ago

While it's not documented on purpose, it's possible with setting the environment variable FIREBASE_CREDENTIALS with the minified output of the JSON file. You can create it, for example, with jq and the following command

$ jq -c . < /path/to/service_account.json
jansgescheit commented 3 years ago

@jeromegamez thanks for the hint, i could have guessed that too. I put the content of the service_account.json to that environment. Works like a charm!