Added in fixes found during manual testing of Azure import.

Change-Id: Icf21d58732fdf4e3caaca015bc10d84613d0f423
This commit is contained in:
Patrick Jones
2021-02-10 17:39:58 -08:00
parent 66670185b0
commit f9a44934e9
4 changed files with 11 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strconv"
@@ -63,9 +64,12 @@ func ExchangeToken(ctx context.Context, endpoint string, request *STSTokenExchan
}
defer resp.Body.Close()
bodyJson := json.NewDecoder(io.LimitReader(resp.Body, 1<<20))
body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20))
if c := resp.StatusCode; c < 200 || c > 299 {
return nil, fmt.Errorf("oauth2/google: status code %d: %s", c, string(body))
}
var stsResp STSTokenExchangeResponse
err = bodyJson.Decode(&stsResp)
json.Unmarshal(body, &stsResp)
if err != nil {
return nil, fmt.Errorf("oauth2/google: failed to unmarshal response body from Secure Token Server: %v", err)