diff --git a/config.go b/config.go index 2cefcd4..4d2ee05 100644 --- a/config.go +++ b/config.go @@ -74,13 +74,13 @@ func (c *Config) RequestToken() (requestToken, requestSecret string, err error) } // when err is nil, resp contains a non-nil resp.Body which must be closed defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return "", "", fmt.Errorf("oauth1: Server returned status %d", resp.StatusCode) + } body, err := ioutil.ReadAll(resp.Body) if err != nil { return "", "", err } - if resp.StatusCode != http.StatusOK { - return "", "", fmt.Errorf("oauth1: Server returned status %d", resp.StatusCode) - } // ParseQuery to decode URL-encoded application/x-www-form-urlencoded body values, err := url.ParseQuery(string(body)) if err != nil {