diff --git a/auth/refresh_token.go b/auth/refresh_token.go index 4e3efb5..3257336 100644 --- a/auth/refresh_token.go +++ b/auth/refresh_token.go @@ -10,7 +10,7 @@ import ( "regexp" "time" - goahttp "goa.design/goa/http" + goahttp "goa.design/goa/v3/http" ) // refreshTokenSource contains the logic to create new session using OAuth tokens @@ -61,10 +61,6 @@ func (ts *refreshTokenSource) TokenString() (string, error) { } defer resp.Body.Close() - jsonBytes, err := ioutil.ReadAll(resp.Body) - if err != nil { - return "", fmt.Errorf("Authentication failed (failed to read response): %s", err) - } if resp.StatusCode != 200 { body, err := ioutil.ReadAll(resp.Body) var msg string @@ -77,6 +73,10 @@ func (ts *refreshTokenSource) TokenString() (string, error) { return "", fmt.Errorf("Authentication failed: %s%s", resp.Status, msg) } + jsonBytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + return "", fmt.Errorf("Authentication failed (failed to read response): %s", err) + } var g Grant err = json.Unmarshal(jsonBytes, &g) if err != nil { diff --git a/cmd/fpt/ChangeLog.md b/cmd/fpt/ChangeLog.md index 424e13d..c553fc4 100644 --- a/cmd/fpt/ChangeLog.md +++ b/cmd/fpt/ChangeLog.md @@ -1,3 +1,7 @@ +v1.1.4 / 2020-06-30 +------------------- +* Remove double read of access token response for non-200 codes so the actual error message comes through + v1.1.3 / 2020-06-26 ------------------- * Fix an incorrect use of `fmt.Printf` without a format to use `fmt.Print` instead diff --git a/go.mod b/go.mod index 6874d31..8420697 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/kingpin v2.2.6+incompatible github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect - github.com/douglaswth/rsrdp v0.0.0-20151016234338-276cfcdf9e52 // indirect + github.com/douglaswth/rsrdp v0.0.0-20151016234338-276cfcdf9e52 github.com/go-yaml/yaml v2.1.0+incompatible github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf github.com/jessevdk/go-flags v1.4.0 // indirect @@ -18,7 +18,6 @@ require ( github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d github.com/spf13/afero v1.2.0 // indirect github.com/spf13/viper v1.3.1 - goa.design/goa v1.0.1-0.20190123214405-b70dea21c455 goa.design/goa/v3 v3.0.6 goa.design/plugins/v3 v3.0.6 golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 diff --git a/go.sum b/go.sum index a7e9a26..7ee5c46 100644 --- a/go.sum +++ b/go.sum @@ -158,8 +158,6 @@ github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea/go.mod h go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -goa.design/goa v1.0.1-0.20190123214405-b70dea21c455 h1:8fsnD0i0VNaNbPZld+JdrOe6VHbFE10vejJtTmj4gqM= -goa.design/goa v1.0.1-0.20190123214405-b70dea21c455/go.mod h1:NnzBwdNktihbNek+pPiFMQP9PPFsUt8MMPPyo9opDSo= goa.design/goa/v3 v3.0.6 h1:+h46Nymbp7ZvRuWwNpAra+l96KKHXjznYiWPKnz8G9I= goa.design/goa/v3 v3.0.6/go.mod h1:sEWV8VRLZenziAnHcIHjjGvlC2pwEvNblwBtMuyPwqQ= goa.design/plugins/v3 v3.0.6 h1:hL3jioHp4z6KQ5L0RnbbB4zE8/U+btbWXgTYBElo/BI=