googleapis / nodejs-pubsub

Node.js client for Google Cloud Pub/Sub: Ingest event streams from anywhere, at any scale, for simple, reliable, real-time stream analytics.
https://cloud.google.com/pubsub/
Apache License 2.0
516 stars 227 forks source link

How do I use a pre-existing OAuth2 token to authenticate a cloud pubsub client? #1912

Closed lucasvickers closed 2 months ago

lucasvickers commented 2 months ago

I'm trying to use a pre-existing OAuth2 token to authenticate a cloud pubsub client. I'm using @google-cloud/pubsub@4.3.3, and google-auth-library@9.9.0.

I'm attempting the following

 token = "..."

  const oAuth2Client = new OAuth2Client();
  oAuth2Client.setCredentials({access_token: token});

  const pubsub = new PubSub({
    projectId: projectId,
    auth: oAuth2Client
  });

  const [topics] = await pubsub.getTopics();

However I get a failure in grpc.tk:418. universeDomain is available as a property (and correctly populated), however the .getUniverseDomain getter does not exist.

What am I missing?

lucasvickers commented 2 months ago

Looks like this is a gax issue https://github.com/googleapis/gax-nodejs/issues/1557