Skip to content

Commit 2bc19b1

Browse files
committed
google/downscope: return body in error message
Change-Id: Ic424a95895668c2f37ffdcea2e3012e4c929cbe5 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/343689 Reviewed-by: Tyler Bui-Palsulich <[email protected]> Trust: Tyler Bui-Palsulich <[email protected]> Trust: Cody Oss <[email protected]> Run-TryBot: Cody Oss <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 7df4dd6 commit 2bc19b1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

google/downscope/downscoping.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,10 @@ func (dts downscopingTokenSource) Token() (*oauth2.Token, error) {
178178
defer resp.Body.Close()
179179
respBody, err := ioutil.ReadAll(resp.Body)
180180
if err != nil {
181-
return nil, fmt.Errorf("downscope: unable to read reaponse body: %v", err)
181+
return nil, fmt.Errorf("downscope: unable to read response body: %v", err)
182182
}
183183
if resp.StatusCode != http.StatusOK {
184-
b, err := ioutil.ReadAll(resp.Body)
185-
if err != nil {
186-
return nil, fmt.Errorf("downscope: unable to exchange token; %v. Failed to read response body: %v", resp.StatusCode, err)
187-
}
188-
return nil, fmt.Errorf("downscope: unable to exchange token; %v. Server responsed: %v", resp.StatusCode, string(b))
184+
return nil, fmt.Errorf("downscope: unable to exchange token; %v. Server responded: %s", resp.StatusCode, respBody)
189185
}
190186

191187
var tresp downscopedTokenResponse

0 commit comments

Comments
 (0)