firebase / firebase/firebase-admin-node

Unable to authenticate using GOOGLE_APPLICATION_CREDENTIALS

Abierto
#2,153 11 comentarios 0 reacciones 1 asignado Reclamado por @lahirumaramba Ver en GitHub
needs-triage
Lenguaje dominante
TypeScript
Estrellas
1.7k
Forks
419
Merge medio
3 d 10 h
PR fusionados (30 d)
16

Descripción

### Environment

* Operating System: MacOS Monterey (12.6.3)
* Firebase SDK Version: 11.6.0
* Firebase Product: Firestore
* Node.js Version: v16.19.1
* NPM Version: 8.19.3

### Description
We're unable to authenticate using the GOOGLE_APPLICATION_CREDENTIALS environment variable, which worked previously.

This is possibly related to this depreciation, as I believe the last time we were able to successfully authenticate was prior to March 31st 2023.

```
// From: https://developers.google.com/identity/sign-in/web/sign-in

Warning: The support of Google Sign-In JavaScript platform library for Web is set to be [deprecated](https://developers.googleblog.com/2021/08/gsi-jsweb-deprecation.html) after March 31, 2023. The solutions in this guide are based on this library and therefore also deprecated.Warning: The support of Google Sign-In JavaScript platform library for Web is set to be [deprecated](https://developers.googleblog.com/2021/08/gsi-jsweb-deprecation.html) after March 31, 2023. The solutions in this guide are based on this library and therefore also deprecated.
```

The issue seems to not be limited to firebase-admin-node, as people are seeing the same error with [firebase-tools](https://github.com/firebase/firebase-tools/issues/5650).

#### Example Code
```
// Using the private key generated from:
// https://console.firebase.google.com/project//settings/serviceaccounts/adminsdk

process.env.GOOGLE_APPLICATION_CREDENTIALS =
"./gcp-service-account-staging.json";

import Firebase from "firebase-admin";

Firebase.initializeApp();

Promise.resolve().then(() => {
return Firebase.firestore()
.collection("usersPublic")
.get()
.then((querySnapshot) => {
querySnapshot.docs.forEach((documentSnapshot) => {
console.log(documentSnapshot.id);
});
});
});
```
#### Error:
(The error persists even when generating a new private key, so I don't believe the error message stating ACCESS_TOKEN_EXPIRED is accurate)
```
{
code: 16,
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.',
metadata: Metadata {
internalRepr: Map(3) {
'google.rpc.errorinfo-bin' => [
Buffer(125) [Uint8Array] [
10, 20, 65, 67, 67, 69, 83, 83, 95, 84, 79, 75,
69, 78, 95, 69, 88, 80, 73, 82, 69, 68, 18, 14,
103, 111, 111, 103, 108, 101, 97, 112, 105, 115, 46, 99,
111, 109, 26, 35, 10, 7, 115, 101, 114, 118, 105, 99,
101, 18, 24, 102, 105, 114, 101, 115, 116, 111, 114, 101,
46, 103, 111, 111, 103, 108, 101, 97, 112, 105, 115, 46,
99, 111, 109, 26, 48, 10, 6, 109, 101, 116, 104, 111,
100, 18, 38, 103, 111, 111, 103, 108, 101, 46, 102, 105,
114, 101, 115, 116,
... 25 more items
]
],
'grpc-status-details-bin' => [
Buffer(385) [Uint8Array] [
8, 16, 18, 208, 1, 82, 101, 113, 117, 101, 115, 116,
32, 104, 97, 100, 32, 105, 110, 118, 97, 108, 105, 100,
32, 97, 117, 116, 104, 101, 110, 116, 105, 99, 97, 116,
105, 111, 110, 32, 99, 114, 101, 100, 101, 110, 116, 105,
97, 108, 115, 46, 32, 69, 120, 112, 101, 99, 116, 101,
100, 32, 79, 65, 117, 116, 104, 32, 50, 32, 97, 99,
99, 101, 115, 115, 32, 116, 111, 107, 101, 110, 44, 32,
108, 111, 103, 105, 110, 32, 99, 111, 111, 107, 105, 101,
32, 111, 114, 32,
... 285 more items
]
],
'www-authenticate' => [ 'Bearer realm="https://accounts.google.com/"' ]
},
options: {}
},
statusDetails: [
ErrorInfo {
metadata: {
service: 'firestore.googleapis.com',
method: 'google.firestore.v1.Firestore.RunQuery'
},
reason: 'ACCESS_TOKEN_EXPIRED',
domain: 'googleapis.com'
}
],
reason: 'ACCESS_TOKEN_EXPIRED',
domain: 'googleapis.com',
errorInfoMetadata: {
service: 'firestore.googleapis.com',
method: 'google.firestore.v1.Firestore.RunQuery'
}
}
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.