Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default Boilerplate error message #301

Open
DarkArtistry opened this issue Apr 23, 2018 · 11 comments
Open

default Boilerplate error message #301

DarkArtistry opened this issue Apr 23, 2018 · 11 comments

Comments

@DarkArtistry
Copy link

Hi,

i'm new to this, i would like to ask of this issue i'm facing after running yarn build and yarn start :

Error: Failed to parse private key: Error: Invalid PEM formatted message.
at FirebaseAppError.FirebaseError [as constructor] (/Users/zhenhaowu/code/freelance/TodoList/node_modules/firebase-admin/lib/utils/error.js:39:28)
at FirebaseAppError.PrefixedFirebaseError [as constructor] (/Users/zhenhaowu/code/freelance/TodoList/node_modules/firebase-admin/lib/utils/error.js:85:28)
at new FirebaseAppError (/Users/zhenhaowu/code/freelance/TodoList/node_modules/firebase-admin/lib/utils/error.js:119:28)
at new Certificate (/Users/zhenhaowu/code/freelance/TodoList/node_modules/firebase-admin/lib/auth/credential.js:129:19)
at new CertCredential (/Users/zhenhaowu/code/freelance/TodoList/node_modules/firebase-admin/lib/auth/credential.js:192:64)
at Object.cert (/Users/zhenhaowu/code/freelance/TodoList/node_modules/firebase-admin/lib/firebase-namespace.js:224:58)
at Object../src/app.node.js (/Users/zhenhaowu/code/freelance/TodoList/build/app.js:792:37)
at webpack_require (/Users/zhenhaowu/code/freelance/TodoList/build/app.js:645:30)
at /Users/zhenhaowu/code/freelance/TodoList/build/app.js:713:55
at Object. (/Users/zhenhaowu/code/freelance/TodoList/build/app.js:716:10)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)

@kudzuu
Copy link

kudzuu commented Apr 25, 2018

You have to navigate to https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk
and create Private Key there.

@andrewkslv
Copy link
Member

Hey @DarkArtistry. Does @kudzuu answer solve your issue?

@Jakobovski
Copy link

Jakobovski commented Jun 23, 2018

And then update FIREBASE_SERVICE_KEY in .env to the new private key. Make sure to have to put it all on one line, or else JSON parser wont work!

@Jakobovski
Copy link

This should be added to the getting started

@kudzuu
Copy link

kudzuu commented Jun 23, 2018

@Jakobovski you can create pull-request <)

@DarkArtistry
Copy link
Author

i will try it out and let you guys know !

@ryanblakeley
Copy link

ryanblakeley commented Oct 6, 2018

what is the .env variable supposed to be? in the project there is GCP_SERVICE_KEY which is in the shape of a firebase generated key. In the console I get the same error for this issue: Warning, FIREBASE_CONFIG environment variable is missing. Initializing firebase-admin will fail, then @Jakobovski says FIREBASE_SERVICE_KEY. If I grep the project the only one of these that shows up outside of .env is here https://github.com/kriasoft/react-firebase-starter/blob/master/src/server/index.js#L21

I tried to follow the boilerplate instructions and added all the env vars to .env.local, including GCP_SERVICE_KEY with a key from Firebase put on one line without spaces. The two things I notice messing up are the error in the console about missing FIREBASE_CONFIG and the routes /admin/users and /admin/stories render blank pages (when logged in to the app with a couple existing users and stories).

Edit: I got past some of the error messages by configuring the deploy and getting that to work. But the admin pages (/admin/users and /admin/stories) are still blank. Looking at the react code those are just setup to render children but it's not clear that children are passed in anywhere. Do those pages ever work or are they like a starting point example that isn't supposed to render anything yet?

Edit: more digging, found that the migration defaults to creating users with is_admin: false. If I override this to be true, either in the migration or in the resolver, the admin pages are still blank.

@johndevor
Copy link

+1

@signalprime
Copy link

+1 to learn more about gcp_service_key, including the format expected for
app.jwt_secret="xxxxx" in

$ firebase --project=example-prod functions:config:set \
    app.app_origin="https://example.com" \
    app.gcp_service_key="xxxxx" \
    app.gcp_server_key="xxxxx" \
    app.jwt_secret="xxxxx" \
    app.google_client_id="xxxxx" \
    app.google_client_secret="xxxxx" \
    app.facebook_app_id="xxxxx" \
    app.facebook_app_secret="xxxxx" \
    app.pgdatabase="xxxxx" \
    app.password="xxxxx"

@kudzuu
Copy link

kudzuu commented Oct 9, 2019

@greg234234 @rojobuffalo I don't see any problem in getting this app. running. You can download whole json config from firebase console and place it under app. directory.

@mahmoudZakaria90
Copy link

Your key inside your .env must be wrapped inside a single and double qoutes in the same time like this
'"[PRIVATE_KEY]"' which indeed the same format you will get from heroku when you call this command
$ heroku config:get PRIVATE_KEY -s >> .env

One more thing to add to JSON.parse in case it stills gets you an error which you will find in here:

https://stackoverflow.com/questions/50299329/node-js-firebase-service-account-private-key-wont-parse

So after you came back from that page, the final code line will look like this:
JSON.parse(process.env.PRIVATE_KEY).replace(/\\n/g, '\n')

golembeskia added a commit to golembeskia/api that referenced this issue Aug 17, 2021
modified line 46 as specified here: kriasoft/react-firebase-starter#301. Also added '" "' around .env variable in heroku
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants