@@ -553,26 +553,35 @@ func importWithBcrypt(ctx context.Context, client *auth.Client) {
553
553
554
554
func importWithScrypt (ctx context.Context , client * auth.Client ) {
555
555
// [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
562
563
}
563
- b64decode := func (s string ) []byte {
564
+ b64Stddecode := func (s string ) []byte {
564
565
b , err := base64 .StdEncoding .DecodeString (s )
565
566
if err != nil {
566
567
log .Fatalln ("Failed to decode string" , err )
567
568
}
568
569
return b
569
570
}
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
+ }
570
579
571
580
// All the parameters below can be obtained from the Firebase Console's "Users"
572
581
// section. Base64 encoded parameters must be decoded into raw bytes.
573
582
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" ),
576
585
Rounds : 8 ,
577
586
MemoryCost : 14 ,
578
587
}
0 commit comments