Firebase-admin-node: FR: support createCustomToken using default google credentials

Created on 7 Mar 2018  路  10Comments  路  Source: firebase/firebase-admin-node

Firebase functions need custom credentials to use createCustomToken() for now. Looks like a missing functionality, we need to manage different credentials for each environment just to use createCustomToken(). There is no reason to not support createCustomToken() using default google credentials.

auth feature request

Most helpful comment

@manishtpatel This is in our roadmap. Can't provide a specific timeline yet, but please know that this is definitely something we wish to support.

All 10 comments

In a second thought could be encryption of the token issue with different credentials.

@manishtpatel This is in our roadmap. Can't provide a specific timeline yet, but please know that this is definitely something we wish to support.

Coming from https://github.com/firebase/firebase-functions/issues/3.

With Firebase Functions v1.0 no longer supporting manually setting the certificate; is there any update on this? Alternatively, can support be added back to the Admin API to allow manually setting the certificate?

Is there an alternative way to enable createCustomToken on Firebase Functions?

+1

admin.initializeApp() still accepts the same parameters as before -- nothing has changed here. You can parse a service account file, and specify a certificate credential as shown here: https://firebase.google.com/docs/admin/setup#initialize_the_sdk

Firebase Auth and Admin SDK will make this use case easier to implement in a future release, but for now you should manually pass the certificate credential.

@hiranya911 Yup, did that instead and works fine! Thanks

I've started making some progress towards supporting this use case (creating custom tokens without a service account). My first attempt is now undergoing testing in the https://github.com/firebase/firebase-admin-node/tree/hkj-jwt-sign branch. Stay tuned.

@hiranya911 I hope your PR will be merged soon, I'm trying to upgrade firebase functions to version 1 and I use createCustomToken in my oauth functions but

admin.initializeApp();

complains because Error: createCustomToken() requires a certificate with "private_key" set.

and

admin.initializeApp({
  credential: admin.credential.cert(account),
  projectId: process.env.FIREBASE_CONFIG.projectId,
  databaseURL: process.env.FIREBASE_CONFIG.databaseURL,
  storageBucket: process.env.FIREBASE_CONFIG.storageBucket,
});

complains because Error: Can't determine Firebase Database URL.

I think I'll have to revert back

+1

This feature is now implemented.

Was this page helpful?
0 / 5 - 0 ratings