Ejemplo n.º 1
0
        private void CheckIfSecretsAreAvailable()
        {
            //Check if credentials are there. If not, we get them from the server.
            //Also check if credentials are meaningful or just dummy credentials. We had
            //incidents where we stored a, b, or c as dummy credentials. In this case, the
            //following check should detect these dummy credentials and replace them with the real ones.
            if (SecretStorage.GetFibitFirstAuthorizationCode() == null ||
                SecretStorage.GetFitbitClientID() == null ||
                SecretStorage.GetFitbitClientSecret() == null ||
                SecretStorage.GetFibitFirstAuthorizationCode().Length <= 1 ||
                SecretStorage.GetFitbitClientID().Length <= 1 ||
                SecretStorage.GetFitbitClientSecret().Length <= 1)
            {
                try
                {
                    AccessDataService.AccessDataClient client = new AccessDataService.AccessDataClient();

                    string authorizationCode = client.GetFitbitFirstAuthorizationCode();
                    if (authorizationCode != null)
                    {
                        SecretStorage.SaveFitbitFirstAuthorizationCode(authorizationCode);
                    }

                    string clientID = client.GetFitbitClientID();
                    if (clientID != null)
                    {
                        SecretStorage.SaveFitbitClientID(clientID);
                    }

                    string clientSecret = client.GetFitbitClientSecret();
                    if (clientSecret != null)
                    {
                        SecretStorage.SaveFitbitClientSecret(clientSecret);
                    }
                }

                catch (Exception e)
                {
                    Logger.WriteToLogFile(e);
                }
            }
        }
Ejemplo n.º 2
0
 public void ReplaceDummyFitbitCredentialsTest()
 {
     SecretStorage.SaveFitbitClientID("a");
     SecretStorage.SaveFitbitClientSecret("b");
     SecretStorage.SaveFitbitFirstAuthorizationCode("c");
 }