Firestore updates SOMETIMES fail with error "Error: 16 UNAUTHENTICATED: Request had invalid authentication credentials."

Viewed 489

I am using "firebase-admin" (v6.4.0) npm package in nodejs (v6.9.4) to connect with firestore (using a service account .json file).

Everything works fine (read/updates work properly) BUT SOMETIMES I receive

"Error: 16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential."

Entire ERROR -

{ Error: 16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
    at Object.exports.createStatusError (/home/ec2-user/socialhelpouts/deployment/social-helpouts/node_modules/google-gax/node_modules/grpc/src/common.js:87:15)
    at Object.onReceiveStatus (/home/ec2-user/socialhelpouts/deployment/social-helpouts/node_modules/google-gax/node_modules/grpc/src/client_interceptors.js:1214:28)
    at InterceptingListener._callNext (/home/ec2-user/socialhelpouts/deployment/social-helpouts/node_modules/google-gax/node_modules/grpc/src/client_interceptors.js:590:42)
    at InterceptingListener.onReceiveStatus (/home/ec2-user/socialhelpouts/deployment/social-helpouts/node_modules/google-gax/node_modules/grpc/src/client_interceptors.js:640:8)
    at callback (/home/ec2-user/socialhelpouts/deployment/social-helpouts/node_modules/google-gax/node_modules/grpc/src/client_interceptors.js:867:24)
  code: 16,
  metadata: Metadata { _internal_repr: { 'www-authenticate': [Object] } },
  details: 'Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.' }

I have read this post and used chrony as suggested by my cloud provider AWS here to keep my server time in sync. Time is in sync now, but I still receive the same error.

Since it works most (~95%) of the time and fails occasionally (with exactly the same code), I don't have a reproducible code.

0 Answers
Related