Пример #1
0
        private async Task<FitBitUser> RefreshToken(string refresh_token, string user_name)
        {

            MongoDataModel dm = new MongoDataModel(ConfigurationManager.AppSettings["MongoDefaultDatabase"].ToString());
            FitBitDataService FitData = new FitBitDataService(dm);

            FitbitContext fitContext = new FitbitContext();

            Authenticator2 authenticator = new Authenticator2(fitContext.ClientId, fitContext.ConsumerSecret, Request.Url.GetLeftPart(UriPartial.Authority) + "/Fitbit/Callback");

            OAuth2AccessToken access_token = await authenticator.RefreshAccessTokenAsync(refresh_token);
            //TODO: update the database with the new token

            FitBitUser user = await getNewUser(access_token);
            
            //update the user token
            await FitData.ModifyFitBitUser(user);
            return user;
        }
Пример #2
0
 // Test method for updating a user information
 public async Task<int> testModifyFitbitUser() {
     MongoDataModel dm = new MongoDataModel(ConfigurationManager.AppSettings["MongoDefaultDatabase"].ToString());
     FitBitDataService FitData = new FitBitDataService(dm);
     FitBitUser user = FitData.GetFitBitUserByName("Pranay Pradhananga");
     user.expires_in = 3600;
     user.refresh_token = "d6e0f9e8d185534928067420392eb97d2a16be2ffce31f9f0379f3a7fddb125a";
     user.access_token = "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NDc3MTQxMjMsInNjb3BlcyI6Indwcm8gd2xvYyB3aHIgd2FjdCIsInN1YiI6IjNNSzY5OSIsImF1ZCI6IjIyOVc4SiIsImlzcyI6IkZpdGJpdCIsInR5cCI6ImFjY2Vzc190b2tlbiIsImlhdCI6MTQ0NzcxMDUyM30.oiuanmhdqkBpvueI5NW_Dn0zZNr9u0gQZXSoToBlBxc";
     user.token_type = "Bearer";
     await FitData.ModifyFitBitUser(user);
     return 1;
 }