0

I was trying to create custom tokens using the Firebase Admin SDK. But while importing import * as admin from 'firebase-admin'; as shown here.

I got an error process.binding is not supported.

I'm using

  • browserify: 14.0.0
  • firebase: ^3.6.8
  • firebase-admin: ^4.1.0

Any ideas on how to resolve this?

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
hvardhan
  • 460
  • 8
  • 14

2 Answers2

2

Since you're using browserify and import syntax instead of the node.js module require syntax, it sounds like you're trying to use the Firebase Admin SDK in the browser. The admin SDK is only for use on a server, and is not for end-user access (see the warning at the top of the Add the Firebase Admin SDK to your Server page).

If you are trying to use the JavaScript SDK for end-user access, follow this guide instead.

If you are using this on a node.js server, try using the require syntax instead:

var admin = require("firebase-admin");

Jeff
  • 2,425
  • 1
  • 18
  • 43
  • `var admin = require("firebase-admin");` didn't help. I'm getting the same error. – hvardhan Feb 03 '17 at 21:22
  • I'm using React + Firebase – hvardhan Feb 03 '17 at 21:27
  • 1
    As I said in my answer above, the Firebase Admin SDK is meant to only be used on a server, not in the browser. Can you explain why you are trying to use it with React? For an excellent guide to getting started with React + Firebase, check out [this video](https://www.youtube.com/watch?v=mwNATxfUsgI). – Jeff Feb 03 '17 at 21:45
  • I was trying to setup OAuth using Github and persist the login on refresh by saving the token in localStorage. For persisting login, I needed a custom token to sign in with the custom token and to create a custom token, I was using the Firebase SDK. – hvardhan Feb 04 '17 at 02:47
  • Is there any way to get token for logged in user? Previously, we could do something like `authData.token` but now we get something like `authData.credential.accessToken` which shows as an invalid custom token by Firebase. – hvardhan Feb 04 '17 at 03:32
  • You can use the Firebase web SDK to sign in to Github once you enable Github as a sign in method in the "Authentication" section of your Firebase console. For the absolute easiest answer, I suggest using the excellent Firebase-UI https://github.com/firebase/firebaseui-web#using-firebaseui-for-authentication Here is a guide with some more info: https://firebase.google.com/docs/auth/web/github-auth – Jeff Feb 06 '17 at 19:01
0

I am using Webpack for a Node application which uses firebase-admin. The solution seemed to be to set target in the Webpack configuration file to 'node'.

Chris Talman
  • 1,059
  • 2
  • 14
  • 24