Я использую пакет "firebase-admin" (v6.4.0) npm в nodejs (v6.9.4) для соединения с firestore (используя файл .json учетной записи службы).
Все отлично работает (чтение / обновления работают правильно) НО ИНОГДА Я получаю
"Error: 16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential."
Полная ОШИБКА -
{ 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.' }
Я прочитал этот пост и использовал chrony , как предложено моим облачным провайдером AWS здесь , чтобы синхронизировать время моего сервера.
Время синхронизировано, но я все еще получаю ту же ошибку.
Поскольку он работает большую часть времени (~ 95%) и иногда дает сбой (с точно таким же кодом), у меня нет воспроизводимого кода.