From f0eb3b0310c6ce0e90aeb79072706d1ba74e300a Mon Sep 17 00:00:00 2001 From: upodroid Date: Wed, 7 Apr 2021 00:05:11 +0100 Subject: [PATCH] don't try to rework credentials field --- backend/remote-state/gcs/backend.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/remote-state/gcs/backend.go b/backend/remote-state/gcs/backend.go index 434b39b5b..a64479a05 100644 --- a/backend/remote-state/gcs/backend.go +++ b/backend/remote-state/gcs/backend.go @@ -151,6 +151,7 @@ func (b *Backend) configure(ctx context.Context) error { if tokenSource != nil { opts = append(opts, option.WithTokenSource(tokenSource)) } else if creds != "" { + var account accountFile // to mirror how the provider works, we accept the file path or the contents contents, err := backend.ReadPathOrContents(creds) @@ -162,7 +163,14 @@ func (b *Backend) configure(ctx context.Context) error { return fmt.Errorf("Error parsing credentials '%s': %s", contents, err) } - opts = append(opts, optionWithCredentialsJSON(), option.WithScopes(storage.ScopeReadWrite)) + conf := jwt.Config{ + Email: account.ClientEmail, + PrivateKey: []byte(account.PrivateKey), + Scopes: []string{storage.ScopeReadWrite}, + TokenURL: "https://oauth2.googleapis.com/token", + } + + opts = append(opts, option.WithHTTPClient(conf.Client(ctx))) } else { opts = append(opts, option.WithScopes(storage.ScopeReadWrite)) }