forked from Mirrors/oauth2
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 <tbp@google.com> Trust: Tyler Bui-Palsulich <tbp@google.com> Trust: Cody Oss <codyoss@google.com> Run-TryBot: Cody Oss <codyoss@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
7df4dd6e12
commit
2bc19b1117
|
@ -178,14 +178,10 @@ func (dts downscopingTokenSource) Token() (*oauth2.Token, error) {
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
respBody, err := ioutil.ReadAll(resp.Body)
|
respBody, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
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 {
|
if resp.StatusCode != http.StatusOK {
|
||||||
b, err := ioutil.ReadAll(resp.Body)
|
return nil, fmt.Errorf("downscope: unable to exchange token; %v. Server responded: %s", resp.StatusCode, respBody)
|
||||||
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))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var tresp downscopedTokenResponse
|
var tresp downscopedTokenResponse
|
||||||
|
|
Loading…
Reference in New Issue