0

I am trying to use firebase-admin and found some inconsistency. I am trying to write some auth code with google-auth-library and firebase-admin and then got stuck on where to get client_id, client_secret. I feel it is something I can get from admin after initializeApp but failed to figure out how.

const {OAuth2Client} = require('google-auth-library');
const admin = require('firebase-admin');
admin.initializeApp();
const client = new OAuth2Client(
    GOOGLE_CLIENT_ID,      ------> somewhere in `admin`?
    GOOGLE_CLIENT_SECRET,
    GOOGLE_CALLBACK_URL
  );

THanks

derek
  • 9,358
  • 11
  • 53
  • 94

1 Answers1

0

If you are rolling your own auth implementation, you may want to store your id + secret in environment variables.

If you are using the one Firebase provides as part of your app setup, I think you may be reinventing the wheel a bit, I would suggest reading through the documentation to use their code examples as much as possible, as much of this is handled for you by the Firebase SDK automatically.

ehed
  • 804
  • 1
  • 8
  • 18
  • My case is different. I am using server side auth. I need authenticate my firebase function to retrieve gmail information. To do that, I need a Oauth client which requires me to have client key and client secret. See here: https://github.com/googlecodelabs/gcf-gmail-codelab/blob/master/pubsub/index.js#L131-L157 – derek Nov 23 '19 at 21:14
  • So the issue is I cannot get the access token from firebase-admin on server side so I have to reinvent the wheel: storing and retrieving tokens. – derek Nov 23 '19 at 21:57