From: Florian Forster Date: Wed, 10 Jan 2018 13:52:33 +0000 (+0100) Subject: Check status code when calling the subscription API. X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=6023f6eda8e7bc9549966b4e844e35153158335e;p=kraftakt.git Check status code when calling the subscription API. --- diff --git a/gfitsync.go b/gfitsync.go index 7d90df6..614d513 100644 --- a/gfitsync.go +++ b/gfitsync.go @@ -152,6 +152,12 @@ func fitbitGrantHandler(ctx context.Context, w http.ResponseWriter, r *http.Requ } defer res.Body.Close() + if res.StatusCode >= 400 { + data, _ := ioutil.ReadAll(r.Body) + log.Errorf(ctx, "creating subscription failed: status %d %q", res.StatusCode, data) + return fmt.Errorf("creating subscription failed") + } + redirectURL := r.URL redirectURL.Path = "/" redirectURL.RawQuery = ""