I’m trying to get two Cloud Run services in the same VPC to communicate with each other. I’m following this tutorial. The section I linked is the one I’m having problems with. The faulty code right now looks like this:
import { GoogleAuth } from 'google-auth-library';
const auth = new GoogleAuth();
client: any;
clientHeaders: any;
serviceUrl = "https://url"
headers = {
'Content-type': 'application/json; charset=UTF-8',
};
async setup() {
try {
if (!this.client)
this.client = await auth.getIdTokenClient(this.serviceUrl);
const gcloudHeaders = await this.client.getRequestHeaders();
this.headers = {
...gcloudHeaders,
...this.headers,
};
const res = await this.client.request({ url: this.serviceUrl });
console.info(res.data);
} catch (err) {
throw Error(
'could not create an identity token: ' + err.message
);
}
}
This code throws the following error:
Uncaught (in promise) Error: could not create an identity token: o.emitWarning is not a function
at p.setup
Looking into it, it seems to be a nodeJS issue, possibly inside google-auth-library
. Googling the issue doesn’t give me many results, and none speficic to google-auth-library
. Versions:
nodeJS v20.10.0
google-auth-library ^9.7.0
Any ideas?