How to get accessToken directly from google-auth-library

61 Views Asked by At

I have a cloud run in my GCP project, and normally I've used google-auth-library like this

  const auth = new GoogleAuth();
  const client = await auth.getIdTokenClient(url);

  await client.request(...)

And it works fine. But now I need only the accessToken to send request from other HTTP client. So I've tried:

  const auth = new GoogleAuth();
  const client = await auth.getIdTokenClient(url);

  console.log(await client.getAccessToken());

But this gave me na error

Error: No refresh token or refresh handler callback is set

so I don't just get accessToken without implementig refreshing?

0

There are 0 best solutions below