@@ -21,23 +21,20 @@ let userImportRecords = [
2121] ;
2222//[END build_user_list]
2323
24- let userImportOptions = {
25- hash : {
26- algorithm : 'HMAC_SHA256' ,
27- key : Buffer . from ( 'secretKey' )
28- }
29- } ;
30-
3124// [START import_users]
32- admin . auth ( ) . importUsers ( userImportRecords , userImportOptions )
25+ admin . auth ( ) . importUsers ( userImportRecords , {
26+ hash : {
27+ algorithm : 'HMAC_SHA256' ,
28+ key : Buffer . from ( 'secretKey' )
29+ }
30+ } )
3331 . then ( function ( userImportResult ) {
3432 // The number of successful imports is determined via: userImportResult.successCount.
3533 // The number of failed imports is determined via: userImportResult.failureCount.
3634 // To get the error details.
37- userImportResult . forEach ( function ( indexedError ) {
38- // The corresponding user that failed to upload.
39- console . log ( userImportRecords [ indexedError . index ] . uid + ' failed to import' ,
40- indexedError . error ) ;
35+ userImportResult . errors . forEach ( function ( indexedError ) {
36+ // The corresponding user that failed to upload.
37+ console . log ( 'Error ' + indexedError . index , ' failed to import: ' , indexedError . error ) ;
4138 } ) ;
4239 } )
4340 . catch ( function ( error ) {
@@ -150,14 +147,14 @@ admin.auth().importUsers([{
150147 // Must be provided in a byte buffer.
151148 passwordHash : Buffer . from ( 'base64-password-hash' , 'base64' ) ,
152149 // Must be provided in a byte buffer.
153- passwordSalt : Buffer . from ( 'base64-salt' , 'base64' )
150+ passwordSalt : Buffer . from ( 'base64-salt' , 'base64' ) ,
154151} ] , {
155152 hash : {
156153 algorithm : 'SCRYPT' ,
157154 // All the parameters below can be obtained from the Firebase Console's users section.
158155 // Must be provided in a byte buffer.
159156 key : Buffer . from ( 'base64-secret' , 'base64' ) ,
160- saltSeparator : Buffer . from ( 'base64SaltSeparator' , 'base64' ) ,
157+ saltSeparator : Buffer . from ( 'base64SaltSeparator' , 'base64' ) . toString ( ) ,
161158 rounds : 8 ,
162159 memoryCost : 14
163160 }
0 commit comments