(resp *http.Response, context string)
| 647 | } |
| 648 | |
| 649 | func parseOAuthError(resp *http.Response, context string) error { |
| 650 | body, err := io.ReadAll(resp.Body) |
| 651 | if err != nil { |
| 652 | return fmt.Errorf("%s failed with status %d", context, resp.StatusCode) |
| 653 | } |
| 654 | |
| 655 | var oauthErr OAuthErrorResponse |
| 656 | if json.Unmarshal(body, &oauthErr) == nil && oauthErr.ErrorDescription != "" { |
| 657 | return fmt.Errorf("%s: %s", context, oauthErr.ErrorDescription) |
| 658 | } |
| 659 | |
| 660 | return fmt.Errorf("%s failed with status %d: %s", context, resp.StatusCode, string(body)) |
| 661 | } |
no test coverage detected