private void button2_Click(object sender, EventArgs e) { //Example of getting the Auth credentials for the first time by directoring the //user to the fitbit site to get a PIN. // GitHub test from Andy var consumerKey = "b3d888281c9b4e098c26c6d1ce4e9d57"; var consumerSecret = "dc6f84c589c341789967b57e83084572"; var requestTokenUrl = "http://api.fitbit.com/oauth/request_token"; var accessTokenUrl = "http://api.fitbit.com/oauth/access_token"; var authorizeUrl = "http://www.fitbit.com/oauth/authorize"; var a = new Authenticator(consumerKey, consumerSecret, requestTokenUrl, accessTokenUrl, authorizeUrl); var url = a.GetAuthUrlToken(); System.Diagnostics.Process.Start(url); Console.WriteLine("Enter the verification code from the website"); var pin = verificationCodeTextBox.Text; var credentials = a.GetAuthCredentialFromPin(pin); //If you already have your credentials stored then rather than getting the users PIN again //you could just start here var fitbit = new FitbitClient(consumerKey, consumerSecret, credentials.AuthToken, credentials.AuthTokenSecret); var profile = fitbit.GetUserProfile(); Console.WriteLine("Your last weight was {0}", profile.Weight); Console.ReadLine(); }
static void Main(string[] args) { //Example of getting the Auth credentials for the first time by directoring the //user to the fitbit site to get a PIN. var consumerKey = "YOUR_CONSUMER_KEY_HERE"; var consumerSecret = "YOUR_CONSUMER_SECRET_HERE"; var requestTokenUrl = "http://api.fitbit.com/oauth/request_token"; var accessTokenUrl = "http://api.fitbit.com/oauth/access_token"; var authorizeUrl = "http://www.fitbit.com/oauth/authorize"; var a = new Authenticator(consumerKey, consumerSecret,requestTokenUrl,accessTokenUrl,authorizeUrl); RequestToken token = a.GetRequestToken(); var url = a.GenerateAuthUrlFromRequestToken(token, false); Process.Start(url); Console.WriteLine("Enter the verification code from the website"); var pin = Console.ReadLine(); var credentials = a.GetAuthCredentialFromPin(pin, token); //If you already have your credentials stored then rather than getting the users PIN again //you could just start here var fitbit = new FitbitClient(consumerKey, consumerSecret, credentials.AuthToken, credentials.AuthTokenSecret); var profile = fitbit.GetUserProfile(); Console.WriteLine("Your last weight was {0}",profile.Weight); Console.ReadLine(); }
static void Main(string[] args) { var credentials = GetLoginCredentials(); var fitbitClient = new FitbitClient(CONSUMER_KEY, CONSUMER_SECRET, credentials.AuthToken, credentials.AuthTokenSecret); var profile = fitbitClient.GetUserProfile(); Activity dayActivity = fitbitClient.GetDayActivity(DateTime.Today); Console.ReadLine(); }
static void Main(string[] args) { //Example of getting the Auth credentials for the first time by directoring the //user to the fitbit site to get a PIN. var credentials = LoadCredentials(); if (credentials == null) { credentials = Authenticate(); SaveCredentials(credentials); } var fitbit = new FitbitClient(consumerKey, consumerSecret, credentials.AuthToken, credentials.AuthTokenSecret); var profile = fitbit.GetUserProfile(); Console.WriteLine("Your last weight was {0}", profile.Weight); Console.ReadLine(); }
private void FitBitLogin_FormClosed(object sender, FormClosedEventArgs e) { FitbitClient client = new FitbitClient(dash.consumerKey, dash.consumerSecret, dash.oauth_token, dash.oauth_token_secret); List<UserProfile> profiles = client.GetFriends(); dash.loggedInUser = client.GetUserProfile(dash.user_id); profiles.Add(dash.loggedInUser); foreach (UserProfile temp in profiles) { foreach (DictionaryEntry tempUser in dash.users) { User theUser = (User)tempUser.Value; if (theUser.firstName.Equals(temp.DisplayName.ToString())) { theUser.id = temp.EncodedId.ToString(); DateTime today = DateTime.Today; ActivitySummary summary = client.GetSpecificUserDayActivitySummary(theUser.id, today); theUser.statistics["Steps Taken"] = summary.Steps; theUser.statistics["Stairs Climbed"] = summary.Floors; theUser.statistics["Calories Burned"] = summary.CaloriesOut; break; } } } }