googleapis / googleapis/google-cloud-go

storage: Is it possible to use the same client (grpc or rest) on defaultSignBytesFunc?

Open
#12,412 3 comments 0 reactions 1 assignee Assigned to @frq-dev View on GitHub
api: storage type: feature request
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

## Is your feature request related to a problem? Please describe.
I'm not sure if it's problem but the code seems not used the gRPC client to call `SignedURL()` without any options even if using `NewGRPCClient()`.

https://github.com/googleapis/google-cloud-go/blob/storage/v1.55.0/storage/bucket.go#L318-L354

## Describe the solution you'd like
I think it should be used IAM Credentials API gRPC client to call if using Storage API gRPC client.

But `google.golang.org/api/iamcredentials/v1` seems not possible. Instead, `cloud.google.com/go/iam` supports gRPC client.

https://github.com/googleapis/google-cloud-go/blob/iam/v1.5.2/iam/credentials/apiv1/iam_credentials_client.go

I don't know if dependencies with other packages are allowed in `cloud.google.com/go`. If it's okay, it's possible to use gRPC client.

## Describe alternatives you've considered
I'm not tryed but I think it's possible to specify `SignBytes` option with gRPC IAM Credentials API Client like that:

```go
credentialsClient, _ := credentials.NewIamCredentialsClient(ctx)
opts := &storage.SignedURLOptions{
SignBytes: func(bytes []byte) ([]byte, error) {
resp, err := credentialsClient.SignBlob( ...omit... )

var buf []byte
_, err = base64.StdEncoding.Decode(buf, resp.SignedBlob)
if err != nil {
return nil, err
}
return buf, nil
},
}
```
I think supporting gRPC client as the default behavior is better.

## Additional context
N/A

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.