Skip to content

Correct way to put credentials.json directly into .env variable #68

Closed
@chuckienorton

Description

@chuckienorton

This excellent package works great for me when referencing the credentials via file in the .env file. However, we use Heroku for staging/production and only have access to string environment variables.

Following this closed issue #63

I used JQ to minify my file, and then placed it into the .env like this:

FIREBASE_CREDENTIALS={"type":"service_account","project_id" ...

This works without the private key, but with the full json which includes '"private_key":"-----BEGIN PRIVATE KEY-----\n' it throws the following laravel application error: "Failed to parse dotenv file due to unexpected whitespace."

If i enclose the entire thing in apostrophes like this:

FIREBASE_CREDENTIALS='{"type":"service_account","project_id" ... '

I get the following error: "Invalid service account: json_decode error: Control character error, possibly incorrectly encoded"

If i remove the apostrophes so the json can correctly decode, and then attempt to change the private key at all - escaping the spaces or anything like this:

FIREBASE_CREDENTIALS={"type":"service_account","private_key":"-----BEGIN\ PRIVATE\ KEY-----\

i get the following error response when trying to use the service: "openssl_sign(): supplied key param cannot be coerced into a private key",…}"

What is the correct format for the FIREBASE_CREDENTIALS variable?

Thanks in advance!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions