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(); }
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(); }
private static AuthCredential GetLoginCredentials() { const string requestTokenUrl = "http://api.fitbit.com/oauth/request_token"; const string accessTokenUrl = "http://api.fitbit.com/oauth/access_token"; const string authorizeUrl = "http://www.fitbit.com/oauth/authorize"; var a = new Authenticator(CONSUMER_KEY, CONSUMER_SECRET, requestTokenUrl, accessTokenUrl, authorizeUrl); var url = a.GetAuthUrlToken(); Process.Start(url); Console.WriteLine("Enter the verification code from the website"); var pin = Console.ReadLine(); var credentials = a.GetAuthCredentialFromPin(pin); return credentials; }
static AuthCredential Authenticate() { 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); return credentials; }