public async Task GetPasswordAsync()

in Mail2Bug/Helpers/CredentialsHelper.cs [30:63]


        public async Task<string> GetPasswordAsync(string dpapiFilePath, System.Security.Cryptography.DataProtectionScope scope, Config.KeyVaultSecret secretsTuple)
        {
            if (secretsTuple == null)
            {
                if (string.IsNullOrWhiteSpace(dpapiFilePath))
                {
                    return null;
                }

                if (!File.Exists(dpapiFilePath)) 
                {
                    throw new BadConfigException("Protected file missing", dpapiFilePath);
                }

                return DPAPIHelper.ReadDataFromFile(dpapiFilePath, scope);
            }

            if (string.IsNullOrWhiteSpace(secretsTuple.ApplicationIdEnvironmentVariableName))
            {
                throw new BadConfigException("Application ID", "Empty Application ID variable name");
            }

            if (string.IsNullOrWhiteSpace(secretsTuple.ApplicationSecretEnvironmentVariableName)) 
            {
                throw new BadConfigException("Application Secret", "Empty Application Secret variable name");
            }

            clientId = GetRequiredEnvironmentVariable(secretsTuple.ApplicationIdEnvironmentVariableName);
            clientSecret = GetRequiredEnvironmentVariable(secretsTuple.ApplicationSecretEnvironmentVariableName);

            var kv = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(GetToken));
            var result = await kv.GetSecretAsync(secretsTuple.KeyVaultPath);
            return result.Value;
        }