@@ -553,26 +553,35 @@ func importWithBcrypt(ctx context.Context, client *auth.Client) {
553553
554554func  importWithScrypt (ctx  context.Context , client  * auth.Client ) {
555555	// [START import_with_scrypt] 
556- 	users  :=  []* auth.UserToImport {
557- 		(& auth.UserToImport {}).
558- 			UID ("some-uid" ).
559- 			Email ("user@example.com" ).
560- 			PasswordHash ([]byte ("password-hash" )).
561- 			PasswordSalt ([]byte ("salt" )),
556+ 	b64URLdecode  :=  func (s  string ) []byte  {
557+ 		b , err  :=  base64 .URLEncoding .DecodeString (s )
558+ 		if  err  !=  nil  {
559+ 			log .Fatalln ("Failed to decode string" , err )
560+ 		}
561+ 
562+ 		return  b 
562563	}
563- 	b64decode  :=  func (s  string ) []byte  {
564+ 	b64Stddecode  :=  func (s  string ) []byte  {
564565		b , err  :=  base64 .StdEncoding .DecodeString (s )
565566		if  err  !=  nil  {
566567			log .Fatalln ("Failed to decode string" , err )
567568		}
568569		return  b 
569570	}
571+ 	// Users retrieved from Firebase Auth's backend need to be base64URL decoded 
572+ 	users  :=  []* auth.UserToImport {
573+ 		(& auth.UserToImport {}).
574+ 			UID ("some-uid" ).
575+ 			Email ("user@example.com" ).
576+ 			PasswordHash (b64URLdecode ("password-hash" )).
577+ 			PasswordSalt (b64URLdecode ("salt" )),
578+ 	}
570579
571580	// All the parameters below can be obtained from the Firebase Console's "Users" 
572581	// section. Base64 encoded parameters must be decoded into raw bytes. 
573582	h  :=  hash.Scrypt {
574- 		Key :           b64decode ("base64-secret" ),
575- 		SaltSeparator : b64decode ("base64-salt-separator" ),
583+ 		Key :           b64Stddecode ("base64-secret" ),
584+ 		SaltSeparator : b64Stddecode ("base64-salt-separator" ),
576585		Rounds :        8 ,
577586		MemoryCost :    14 ,
578587	}
0 commit comments