// // GET: /Authorize/ // Setup - prepare the user redirect to Fitbit.com to prompt them to authorize this app. public async Task<ActionResult> Authorize() { //make sure you've set these up in Web.Config under <appSettings>: string consumerKey = ConfigurationManager.AppSettings["FitbitConsumerKey"]; string consumerSecret = ConfigurationManager.AppSettings["FitbitConsumerSecret"]; var authenticator = new Authenticator(consumerKey, consumerSecret); RequestToken token = await authenticator.GetRequestTokenAsync(); Session.Add("FitbitRequestTokenSecret", token.Secret); //store this somehow, like in Session as we'll need it after the Callback() action //note: at this point the RequestToken object only has the Token and Secret properties supplied. Verifier happens later. string authUrl = authenticator.GenerateAuthUrlFromRequestToken(token, true); return Redirect(authUrl); }
public void Generate_Auth_Url_ForceLogout_False() { var authenticator = new Authenticator("key", "secret"); var url = authenticator.GenerateAuthUrlFromRequestToken(new RequestToken { Token = "something" }, false); Assert.AreEqual("https://api.fitbit.com/oauth/authorize?oauth_token=something", url); }