Firebase admin sdk not working on Apple m1 processor

692 views
Skip to first unread message

Don Morris

unread,
Dec 27, 2020, 6:50:17 PM12/27/20
to Firebase Google Group
I am getting a google auth error when trying to use the firebase admin sdk to read a firestore collection. The same code works fine on my intel mac.

I'm using node v15.4.0 built for arm64 on a macbook air m1.

Here is the error message

/Users/don/.nvm/versions/node/v15.4.0/bin/node /Users/don/Dropbox/Business/PicSaver/code/cloudfunctions/functions/lib/server.js uploads
Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
    at GoogleAuth.getApplicationDefaultAsync (/Users/don/Dropbox/Business/PicSaver/code/cloudfunctions/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:157:19)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async GoogleAuth.getClient (/Users/don/Dropbox/Business/PicSaver/code/cloudfunctions/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:490:17)
    at async GrpcClient._getCredentials (/Users/don/Dropbox/Business/PicSaver/code/cloudfunctions/functions/node_modules/google-gax/build/src/grpc.js:87:24)
    at async GrpcClient.createStub (/Users/don/Dropbox/Business/PicSaver/code/cloudfunctions/functions/node_modules/google-gax/build/src/grpc.js:212:23)

Sam Stern

unread,
Dec 28, 2020, 5:56:06 AM12/28/20
to Firebase Google Group
Hi Don,

For bugs in the Admin SDK the best place to report them is on GitHub:

From the looks of your error stack this bug likely is not related to the M1 processor architecture.  It looks like your computer does not have gcloud credentials.  This is a common thing to forget when getting a new computer, So you have a few options:
  1. If you want to authorize as yourself (end user credentials) install the "gcloud" command line tool and run "gcloud auth application-default login"
  2. If you want to authorize as a service account set the "GOOGLE_APPLICATION_CREDENTIALS" environment variable to the path to a service account JSON key. More information on that approach is here: https://firebase.google.com/docs/admin/setup#initialize-sdk
- Sam

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/38d6a04f-f5fe-48dd-805f-b73e0925f342n%40googlegroups.com.

Don Morris

unread,
Dec 28, 2020, 1:06:40 PM12/28/20
to Firebase Google Group
That fixed the auth issue on my mac.

I'm a bit puzzled though because I didn't do this on my linux server that run the same code with no problems. I have run this code on several ubuntu servers without installing gcloud or logging into my gcloud account.

Sam Stern

unread,
Dec 28, 2020, 1:10:36 PM12/28/20
to Firebase Google Group
Hmmm well those servers have a credential somehow!  If your server is running on Compute Engine, Cloud Functions or another similar trusted Google Cloud environment then the Admin SDK is able to discover the credentials using the private Compute Metadata API.

- Sam

Don Morris

unread,
Dec 28, 2020, 6:39:57 PM12/28/20
to Firebase Google Group
They are running on amazon lightsail.

I'll do some research.

Been a bumpy road trying to get the Mac with m1 chip working correctly for software development. 

Reply all
Reply to author
Forward
0 new messages