X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=gfitsync.go;h=614d513e374384314611581f24cfb6b2c3dc8927;hb=6023f6eda8e7bc9549966b4e844e35153158335e;hp=21f764be528e1d7e36c7814de1447bace88650f4;hpb=89b5d50db6ae20cf598983fdc3c736c53cabaa3d;p=kraftakt.git diff --git a/gfitsync.go b/gfitsync.go index 21f764b..614d513 100644 --- a/gfitsync.go +++ b/gfitsync.go @@ -152,8 +152,16 @@ 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 = "" + redirectURL.Fragment = "" http.Redirect(w, r, redirectURL.String(), http.StatusTemporaryRedirect) return nil }