I'm initializing the firebase config as following,
firebaseAdmin.initializeApp({
credential: applicationDefault(),
projectId: "${my_project_id}",
});
Verify ID token is working,
firebaseAdmin
.app()
.auth()
.verifyIdToken(idToken)
.then((decodedIDToken) => {
console.log("decodedIDToken: ", decodedIDToken);
})
.catch((error) => {
console.log("error: ", error);
})
But getUser is throwing error,
firebaseAdmin
.app()
.auth()
.getUser(uuid)
.then((data) => {
console.log("user: ", data);
})
.catch((error) => {
console.log("error: ", error);
});
Error
errorInfo: {
code: 'auth/internal-error',
message: '//cloud.google.com/docs/authentication/adc-troubleshooting/user-creds . Raw server response: "{"error":{"code":403,"message":"Your application is authenticating by using local Application Default Credentials. The identitytoolkit.googleapis.com API requires a quota project, which is not set by default. To learn how to set your quota project, see https://cloud.google.com/docs/authentication/adc-troubleshooting/user-creds .","errors":[{"message":"Your application is authenticating by using local Application Default Credentials. The identitytoolkit.googleapis.com API requires a quota project, which is not set by default. To learn how to set your quota project, see https://cloud.google.com/docs/authentication/adc-troubleshooting/user-creds .","domain":"usageLimits","reason":"accessNotConfigured","extendedHelp":"https://console.developers.google.com"}],"status":"PERMISSION_DENIED","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"SERVICE_DISABLED","domain":"googleapis.com","metadata":{"service":"identitytoolkit.googleapis.com","consumer":"projects/${some_project_ID"}}]}}"'
},
codePrefix: 'auth'
}
I've ensured to set the correct project to both application-default and default project by running these,
$ gcloud auth application-default set-quota-project ${some_different project}
$ gcloud config set project ${my_project_id}
I've also confirmed both the projects have Identity Toolkit API enabled.