Also subscribe to the "sleep" Fitbit collection.
authorFlorian Forster <ff@octo.it>
Thu, 25 Jan 2018 19:46:42 +0000 (20:46 +0100)
committerFlorian Forster <ff@octo.it>
Thu, 25 Jan 2018 19:46:42 +0000 (20:46 +0100)
fitbit/fitbit.go
gfitsync.go

index 04c50cd..4555e22 100644 (file)
@@ -22,7 +22,12 @@ var oauth2Config = &oauth2.Config{
        ClientSecret: "@FITBIT_CLIENT_SECRET@",
        Endpoint:     oauth2fitbit.Endpoint,
        RedirectURL:  "https://kraftakt.octo.it/fitbit/grant",
        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@"
 }
 
 const csrfToken = "@CSRFTOKEN@"
index 61e9107..7f28bb0 100644 (file)
@@ -130,6 +130,10 @@ func fitbitGrantHandler(ctx context.Context, w http.ResponseWriter, r *http.Requ
                return fmt.Errorf("c.Subscribe() = %v", err)
        }
 
                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 = ""
        redirectURL := r.URL
        redirectURL.Path = "/"
        redirectURL.RawQuery = ""