From 6023f6eda8e7bc9549966b4e844e35153158335e Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 10 Jan 2018 14:52:33 +0100 Subject: [PATCH] Check status code when calling the subscription API. --- gfitsync.go | 6 ++++++ 1 file changed, 6 insertions(+) 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 = "" -- 2.11.0