From 929f793807be2b042e4330fb3f953a1f7a32c5c6 Mon Sep 17 00:00:00 2001 From: Patrick Jones Date: Thu, 12 Nov 2020 11:43:19 -0800 Subject: [PATCH] google: change json decoding layout Change-Id: Idc322fc66cb93e5d61f0c41d5847a2567a5e1019 --- google/internal/externalaccount/sts_exchange.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/google/internal/externalaccount/sts_exchange.go b/google/internal/externalaccount/sts_exchange.go index c2f0626..1bcd661 100644 --- a/google/internal/externalaccount/sts_exchange.go +++ b/google/internal/externalaccount/sts_exchange.go @@ -31,8 +31,8 @@ func ExchangeToken(ctx context.Context, endpoint string, request *STSTokenExchan if err != nil { return nil, fmt.Errorf("oauth2/google: failed to marshal additional options: %v", err) } - data.Set("options", string(opts)) + authentication.InjectAuthentication(data, headers) encodedData := data.Encode() @@ -57,14 +57,13 @@ func ExchangeToken(ctx context.Context, endpoint string, request *STSTokenExchan bodyJson := json.NewDecoder(io.LimitReader(resp.Body, 1<<20)) var stsResp STSTokenExchangeResponse - for bodyJson.More() { - err = bodyJson.Decode(&stsResp) - if err != nil { - return nil, fmt.Errorf("oauth2/google: failed to unmarshal response body from Secure Token Server: %v", err) + err = bodyJson.Decode(&stsResp) + if err != nil { + return nil, fmt.Errorf("oauth2/google: failed to unmarshal response body from Secure Token Server: %v", err) - } } + return &stsResp, nil }