From 6c7b039b319152555c9529d8d5a2c2483cf65887 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 25 Jan 2018 20:46:42 +0100 Subject: [PATCH] Also subscribe to the "sleep" Fitbit collection. --- fitbit/fitbit.go | 7 ++++++- gfitsync.go | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fitbit/fitbit.go b/fitbit/fitbit.go index 04c50cd..4555e22 100644 --- a/fitbit/fitbit.go +++ b/fitbit/fitbit.go @@ -22,7 +22,12 @@ var oauth2Config = &oauth2.Config{ ClientSecret: "@FITBIT_CLIENT_SECRET@", Endpoint: oauth2fitbit.Endpoint, RedirectURL: "https://kraftakt.octo.it/fitbit/grant", - Scopes: []string{"activity", "heartrate", "profile"}, + Scopes: []string{ + "activity", + "heartrate", + "profile", + "sleep", + }, } const csrfToken = "@CSRFTOKEN@" diff --git a/gfitsync.go b/gfitsync.go index 61e9107..7f28bb0 100644 --- a/gfitsync.go +++ b/gfitsync.go @@ -130,6 +130,10 @@ func fitbitGrantHandler(ctx context.Context, w http.ResponseWriter, r *http.Requ return fmt.Errorf("c.Subscribe() = %v", err) } + if err := c.Subscribe(ctx, "sleep"); err != nil { + return fmt.Errorf("c.Subscribe() = %v", err) + } + redirectURL := r.URL redirectURL.Path = "/" redirectURL.RawQuery = "" -- 2.11.0