Example #1
0
        public static void StoreCredentials(OnewheelApiCredentials credentials)
        {
            // Delete existing password vaults:
            DeleteAllVaults();

            // Store the new password:
            if (!string.IsNullOrEmpty(credentials.apiToken))
            {
                PASSWORD_VAULT.Add(new PasswordCredential(credentials.DEVICE_NAME, credentials.apiKey, credentials.apiToken));
            }
        }
Example #2
0
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--


        #endregion
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public static bool LoadCredentials(OnewheelApiCredentials credentials)
        {
            try
            {
                IReadOnlyList <PasswordCredential> pwCredentials = PASSWORD_VAULT.FindAllByResource(credentials.DEVICE_NAME);
                if (pwCredentials.Count >= 1)
                {
                    pwCredentials[0].RetrievePassword();
                    credentials.apiKey   = pwCredentials[0].UserName;
                    credentials.apiToken = pwCredentials[0].Password;
                    return(!string.IsNullOrEmpty(credentials.apiKey) && !string.IsNullOrEmpty(credentials.apiToken));
                }
            }
            catch (Exception e)
            {
                Logger.Error("Failed to retrieve credentials for: " + credentials.DEVICE_NAME, e);
            }
            return(false);
        }