internal static async Task ImportWithScrypt()

in FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAuthSnippets.cs [357:398]


        internal static async Task ImportWithScrypt()
        {
            // [START import_with_scrypt]
            try
            {
                var users = new List<ImportUserRecordArgs>()
                {
                    new ImportUserRecordArgs()
                    {
                        Uid = "some-uid",
                        Email = "user@example.com",
                        PasswordHash = Encoding.ASCII.GetBytes("password-hash"),
                        PasswordSalt = Encoding.ASCII.GetBytes("salt"),
                    },
                };

                var options = new UserImportOptions()
                {
                    // All the parameters below can be obtained from the Firebase Console's "Users"
                    // section. Base64 encoded parameters must be decoded into raw bytes.
                    Hash = new Scrypt()
                    {
                        Key = Encoding.ASCII.GetBytes("base64-secret"),
                        SaltSeparator = Encoding.ASCII.GetBytes("base64-salt-separator"),
                        Rounds = 8,
                        MemoryCost = 14,
                    },
                };

                UserImportResult result = await FirebaseAuth.DefaultInstance.ImportUsersAsync(users, options);
                foreach (ErrorInfo indexedError in result.Errors)
                {
                    Console.WriteLine($"Failed to import user: {indexedError.Reason}");
                }
            }
            catch (FirebaseAuthException e)
            {
                Console.WriteLine($"Error importing users: {e.Message}");
            }

            // [END import_with_scrypt]
        }