Replies: 2 comments 3 replies
-
My code looks like:
-- |
Beta Was this translation helpful? Give feedback.
-
If your server is on Google environment (GCP), initialize the SDK without parameters and the SDK will use the underlying attached service account details from the environment. const firebaseAdminApp = initializeApp(); On non-Google environments, you can set import { initializeApp, applicationDefault } from 'firebase-admin/app';
initializeApp({
credential: applicationDefault(),
projectId: '<FIREBASE_PROJECT_ID>',
}); Your sample code above is also fine if you want to load the private key from an environment variable. Always make sure to keep your service account credentials safe as service accounts give administrative access to your projects. Poorly managed service account keys can introduce security risks. |
Beta Was this translation helpful? Give feedback.
-
Hi. I am using firebase admin SDK to verify ID Token on my backend server.
Firebase App (not admin) suggests it is okay to expose API keys: https://firebase.google.com/docs/projects/api-keys#api-keys-for-firebase-are-different. I suppose keys for admin SDK need more careful handling.
The current Firebase Admin SDK instruction suggests using a JSON private key file: https://firebase.google.com/docs/admin/setup#initialize-sdk
I don't feel comfortable with committing such information in a repository for deployment
Is there an official instruction to initialize the admin app only with environment variable? Also, what are the critical/sensitive data from the private key file? Definitely
private_key
. But how aboutprivate_key_id
orproject_id
?Beta Was this translation helpful? Give feedback.
All reactions