Skip to content

Commit

Permalink
fix: specify scope for WithCredentialsFile/JSON (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtisvg authored May 18, 2022
1 parent 6dd26a3 commit 9424d57
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
apiopt "google.golang.org/api/option"
)

const CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"

// An Option is an option for configuring a Dialer.
type Option func(d *dialerConfig)

Expand Down Expand Up @@ -71,7 +73,8 @@ func WithCredentialsFile(filename string) Option {
// or refresh token JSON credentials to be used as the basis for authentication.
func WithCredentialsJSON(b []byte) Option {
return func(d *dialerConfig) {
c, err := google.CredentialsFromJSON(context.Background(), b) // TODO: add AlloyDB scope
// TODO: Use AlloyDB-specfic scope
c, err := google.CredentialsFromJSON(context.Background(), b, CloudPlatformScope)
if err != nil {
d.err = errtype.NewConfigError(err.Error(), "n/a")
return
Expand Down

0 comments on commit 9424d57

Please sign in to comment.