Skip to content

Commit

Permalink
google/downscope: return body in error message
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
codyoss committed Aug 19, 2021
1 parent 7df4dd6 commit 2bc19b1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions google/downscope/downscoping.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,10 @@ func (dts downscopingTokenSource) Token() (*oauth2.Token, error) {
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("downscope: unable to read reaponse body: %v", err)
return nil, fmt.Errorf("downscope: unable to read response body: %v", err)
}
if resp.StatusCode != http.StatusOK {
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("downscope: unable to exchange token; %v. Failed to read response body: %v", resp.StatusCode, err)
}
return nil, fmt.Errorf("downscope: unable to exchange token; %v. Server responsed: %v", resp.StatusCode, string(b))
return nil, fmt.Errorf("downscope: unable to exchange token; %v. Server responded: %s", resp.StatusCode, respBody)
}

var tresp downscopedTokenResponse
Expand Down

0 comments on commit 2bc19b1

Please sign in to comment.