7

I initialized the SDK Admin in my code, but when I call an admin function it complains about credentials and tokens. Any idea what this could be caused by?

var serviceAccount = require('../../../path to the actual json file);
admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: 'https://<name of my database>.firebaseio.com'
});

Output

Error fetching user data: Error: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: incorrect header check. Error code: Z_DATA_ERROR".
        at FirebaseAppError.FirebaseError [as constructor] (error.js?8304:42)
        at FirebaseAppError.PrefixedFirebaseError [as constructor] (error.js?8304:88)
        at new FirebaseAppError (error.js?8304:122)
        at eval (firebase-app.js?0db4:121)
Community
  • 1
  • 1

1 Answers1

1

The Z_DATA_ERROR suggests that gzip is at fault. Make sure the Firebase Admin SDK has been updated to the latest version.

Also ensure that your computer clock is synchronized.

And finally, check that the Firebase service account and the database URL are for the same project.

Christopher Peisert
  • 21,862
  • 3
  • 86
  • 117