Codebase list golang-golang-x-oauth2 / 2bc19b1
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> Cody Oss 2 years ago
1 changed file(s) with 2 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
177177 defer resp.Body.Close()
178178 respBody, err := ioutil.ReadAll(resp.Body)
179179 if err != nil {
180 return nil, fmt.Errorf("downscope: unable to read reaponse body: %v", err)
180 return nil, fmt.Errorf("downscope: unable to read response body: %v", err)
181181 }
182182 if resp.StatusCode != http.StatusOK {
183 b, err := ioutil.ReadAll(resp.Body)
184 if err != nil {
185 return nil, fmt.Errorf("downscope: unable to exchange token; %v. Failed to read response body: %v", resp.StatusCode, err)
186 }
187 return nil, fmt.Errorf("downscope: unable to exchange token; %v. Server responsed: %v", resp.StatusCode, string(b))
183 return nil, fmt.Errorf("downscope: unable to exchange token; %v. Server responded: %s", resp.StatusCode, respBody)
188184 }
189185
190186 var tresp downscopedTokenResponse