google: change json decoding layout

Change-Id: Idc322fc66cb93e5d61f0c41d5847a2567a5e1019
This commit is contained in:
Patrick Jones 2020-11-12 11:43:19 -08:00
parent 57d1f928e5
commit ccc73e0caf
1 changed files with 5 additions and 6 deletions

View File

@ -31,8 +31,8 @@ func ExchangeToken(ctx context.Context, endpoint string, request *STSTokenExchan
if err != nil { if err != nil {
return nil, fmt.Errorf("oauth2/google: failed to marshal additional options: %v", err) return nil, fmt.Errorf("oauth2/google: failed to marshal additional options: %v", err)
} }
data.Set("options", string(opts)) data.Set("options", string(opts))
authentication.InjectAuthentication(data, headers) authentication.InjectAuthentication(data, headers)
encodedData := data.Encode() encodedData := data.Encode()
@ -57,13 +57,12 @@ func ExchangeToken(ctx context.Context, endpoint string, request *STSTokenExchan
bodyJson := json.NewDecoder(io.LimitReader(resp.Body, 1<<20)) bodyJson := json.NewDecoder(io.LimitReader(resp.Body, 1<<20))
var stsResp STSTokenExchangeResponse var stsResp STSTokenExchangeResponse
for bodyJson.More() {
err = bodyJson.Decode(&stsResp) err = bodyJson.Decode(&stsResp)
if err != nil { if err != nil {
return nil, fmt.Errorf("oauth2/google: failed to unmarshal response body from Secure Token Server: %v", err) return nil, fmt.Errorf("oauth2/google: failed to unmarshal response body from Secure Token Server: %v", err)
} }
}
return &stsResp, nil return &stsResp, nil
} }