auth.ssr.credential issue
I've follow the instruction in doc to Generate a private key from Firebase, then added the .json file into assets folder, and configure the path as such:
auth: {
ssr:
{
credential: '~/assets/servicekey.json',
serverLogin: true
},
}
But the browser shows
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: getaddrinfo ENOTFOUND metadata.google.internal. Error code: ENOTFOUND".
I'm not sure why it cant find the credential. I've tried the .env way (by setting ssr: true), but the same problem persists.
***Another simple question, if I've implemented the firebase-admin successfully, do I need to have a servermiddleware to run the firebase-admin function?
I'm also facing the same issue. I also have tried both ways - by setting credential as path to json and setting environment variable as mentioned here.
'@nuxtjs/firebase',
{
config: {
...
},
services: {
auth: {
persistence: 'local',
intialize : {
onAuthStateChangeAction: 'onAuthStateChanged'
},
ssr: {
credential : '~/serviceAcountKeys.json',
ignorePaths: [
'/api/'
],
}
},
realTimeDb: true,
function: true
}
}
Error Message:
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async module.exports.../functions/nuxt/firebase-module/ssrAuth.js.__webpack_exports__.default (server.js:929:24)
at async createApp (server.js:1273:5)
at async module.exports.../functions/nuxt/server.js.__webpack_exports__.default (server.js:1670:7)
{errorInfo: {
code: 'app/invalid-credential',
message: '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: getaddrinfo ENOTFOUND metadata.google.internal.
Error code: ENOTFOUND".'
codePrefix: 'app'
Update 1: mysteriously the error is resolved. At some point I decided to restart my PC to start server in fresh new node instance, and it worked. :)
i’m experiencing this as well. Unfortunately, restarting my server and/or computer didn’t resolve it.
I was trying to verify id-token in node. I imported firebase-admin, copied id-token from browser, initialized firebase-admin with serviceAccountKey.json. It I was able to verify. After that I got the error 'multiple instances of firebase-admin'. I restarted PC to be little sure to start in fresh node instance. And it worked. See if you're able to verify id-token manually.
@mentAl-maZe Any idea if there is something we can improve here?
I am by no means an experienced developer, but I have tried to follow the docs as closely as possible with the same result as OP:
FirebaseAppError: 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: getaddrinfo ENOTFOUND metadata.google.internal. Error code: ENOTFOUND".
at FirebaseAppError.FirebaseError [as constructor] (/Users/web/project/node_modules/firebase-admin/lib/utils/error.js:42:28)
at FirebaseAppError.PrefixedFirebaseError [as constructor] (/Users/web/project/node_modules/firebase-admin/lib/utils/error.js:88:28)
at new FirebaseAppError (/Users/web/project/node_modules/firebase-admin/lib/utils/error.js:123:28)
at /Users/web/project/node_modules/firebase-admin/lib/firebase-app.js:121:23
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async module.exports../.nuxt/firebase-module/ssrAuth.js.__webpack_exports__.default (server.js:1032:24)
at async createApp (server.js:1334:5)
at async module.exports../.nuxt/server.js.__webpack_exports__.default (server.js:1794:7) {
errorInfo: {
code: 'app/invalid-credential',
message: '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: getaddrinfo ENOTFOUND metadata.google.internal. Error code: ENOTFOUND".'
},
codePrefix: 'app'
}
Please keep in mind that the serverLogin feature is marked as Experimental and therefore might be leading to various issues that we are not actively putting effort into.
If you are not an experience developer I would suggest you to stay away from experimental features. Use the feature for test-purposes and for playing around, but not for productive apps at this point.
I'm unfortunately currently out of capacity to look into issues regarding experimental features, if someone has time feel free to look into it and create a a PR.
@mentAl-maZe, I'm still considering of removing this feature from the module, since it does not seem to be stable enough and I am not sure it ever will be a production ready feature. It also makes the module much more complex to maintain. Are you still thinking of building a separate module for it so we could outsource this?
Closing since outdated - will reevaluate ssr/serverLogin separately.