googleapis / googleapis/google-cloud-node

Error when using access token obtained via gcloud auth print-access-token with @google-cloud/logging v11.2.0

Open
#7,587 0 comments 0 reactions 0 assignees View on GitHub
api: logging priority: p3 type: bug
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

When using the command `gcloud auth print-access-token --lifetime=3600 --impersonate-service-account=xxx` to obtain an `access_token` and calling the following method: https://github.com/googleapis/nodejs-logging/blob/9d1d480406c4d1526c8a7fafd9b18379c0c7fcea/src/log.ts#L610, the following error occurs:

The options sent were:

```
{
orderBy: 'timestamp desc',
resourceNames: [ 'projects/xxx' ],
filter: '\n' +
' resource.type="k8s_pod"\n' +
' resource.labels.cluster_name="xxx"\n' +
' resource.labels.location="asia-northeast1"\n' +
' jsonPayload.reason="Pulled"\n' +
' jsonPayload.metadata.namespace="default"\n' +
' timestamp >= "2024-09-12T08:05:52.957Z"\n' +
' ',
pageSize: 500
}
```

The error returned is:

```
/masked_path/node_modules/google-gax/node_modules/@grpc/grpc-js/src/call.ts:85
}
^
Error: 2 UNKNOWN: Getting metadata from plugin failed with error: key must be a string, a buffer or an object
at callErrorFromStatus (/masked_path/node_modules/google-gax/node_modules/@grpc/grpc-js/src/call.ts:85:2)
at Object.onReceiveStatus (/masked_path/node_modules/google-gax/node_modules/@grpc/grpc-js/src/client.ts:360:55)
at Object.onReceiveStatus (/masked_path/node_modules/google-gax/node_modules/@grpc/grpc-js/src/client-interceptors.ts:458:34)
at Object.onReceiveStatus (/masked_path/node_modules/google-gax/node_modules/@grpc/grpc-js/src/client-interceptors.ts:419:48)
at /masked_path/node_modules/google-gax/node_modules/@grpc/grpc-js/src/resolving-call.ts:163:24
at processTicksAndRejections (node:internal/process/task_queues:77:11)
for call at
at ServiceClientImpl.makeUnaryRequest (/masked_path/node_modules/google-gax/node_modules/@grpc/grpc-js/src/client.ts:325:42)
at ServiceClientImpl. (/masked_path/node_modules/google-gax/node_modules/@grpc/grpc-js/src/make-client.ts:189:15)
at /masked_path/node_modules/@google-cloud/logging/src/v2/logging_service_v2_client.ts:440:9
at wrappedCall (/masked_path/node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js:86:20)
at /masked_path/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16
at repeat (/masked_path/node_modules/google-gax/build/src/normalCalls/retries.js:82:25)
at /masked_path/node_modules/google-gax/build/src/normalCalls/retries.js:125:13
at OngoingCallPromise.call (/masked_path/node_modules/google-gax/build/src/call.js:67:27)
at PagedApiCaller.call (/masked_path/node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js:118:25)
at /masked_path/node_modules/google-gax/build/src/createApiCall.js:112:30 {
code: 2,
details: 'Getting metadata from plugin failed with error: key must be a string, a buffer or an object',
metadata: Metadata { internalRepr: Map(0) {}, options: {} },
note: 'Exception occurred in retry method that was not classified as transient'
}
```

Is this the intended behavior? I understand that access tokens are accepted for authentication by most Google APIs. Does this API not support access tokens? It would be greatly appreciated if access token support could be added.

#### Environment details

- OS: macOS
- Node.js version: 20.18.0
- npm version: 10.8.2
- `@google-cloud/logging` version: v11.2.0

#### Steps to reproduce

1. get access token from `gcloud auth print-access-token --lifetime=3600 --impersonate-service-account=xxx`
2. get logs from getEntries

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.