Imported users from another Firebase Auth project cannot log in

200 views
Skip to first unread message

jo...@optimusride.com

unread,
Mar 7, 2019, 12:47:42 PM3/7/19
to Firebase Google Group
I am attempting to import users exported from a Firebase Auth instance in another project, and am able to import the account into the new environment, but users cannot log in with their new accounts.  I followed the pattern shown here: https://firebase.google.com/docs/auth/admin/import-users#import_users_with_firebase_scrypt_hashed_passwords almost exactly, 
users = [
    auth
.ImportUserRecord(
        uid
='some-uid',
        email
='us...@example.com',
        password_hash
=b'password_hash',
        password_salt
=b'salt'
   
),
]

# All the parameters below can be obtained from the Firebase Console's "Users"
# section. Base64 encoded parameters must be decoded into raw bytes.
hash_alg
= auth.UserImportHash.scrypt(
    key
=base64.b64decode('base64_secret'),
    salt_separator
=base64.b64decode('base64_salt_separator'),
    rounds
=8,
    memory_cost
=14
)
try:
    result
= auth.import_users(users, hash_alg=hash_alg)
   
for err in result.errors:
       
print('Failed to import user:', err.reason)
except auth.AuthError as error:
   
print('Error importing users:', error)

I took the base64_secret and base64_salt_separator from the password hash parameters popup in the old firebase project.  The password hash and password salt I'm using are the ones given in the export file from running 'firebase auth:export' json file, but logging in throws an "INVALID_PASSWORD" error.  If anybody has successfully imported from one firebase project to another with passwords and could provide some advice it'd be appreciated.  I can provide more information on the method i'm using if needed.  

Thanks!

Hiranya Jayathilaka

unread,
Mar 7, 2019, 7:34:42 PM3/7/19
to fireba...@googlegroups.com

Hopefully it will help you figure out what went wrong.

Thanks,
Hiranya 

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/64f07daa-d20c-4386-bc99-02a59e394782%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Hiranya Jayathilaka | Software Engineer | h...@google.com | 650-203-0128

Romel Gomez

unread,
Mar 8, 2019, 11:06:36 AM3/8/19
to fireba...@googlegroups.com
The integration test that you point need an api_key, where I can get that key?.  

is the --cert are the private firebase credentials? 
is the --apikey are the public firebase credentials, e.g for the web client? or the private_key_id of the private firebase credentials?        


def pytest_addoption(parser):
parser.addoption(
'--cert', action='store', help='Service account certificate file for integration tests.')
parser.addoption(
'--apikey', action='store', help='API key file for integration tests.')





Firebase Admin SDK

import firebase_admin
from firebase_admin import credentials

cred
= credentials.Certificate("path/to/serviceAccountKey.json")
firebase_admin
.initialize_app(cred)


serviceAccountKey.json is the private key, the values for --cert and --apikey come from this file? 




Romel Gomez

unread,
Mar 8, 2019, 11:06:53 AM3/8/19
to fireba...@googlegroups.com
The password property hash is in base64 already, but the salt is not.

Import user of django to firebase









Hiranya Jayathilaka

unread,
Mar 8, 2019, 1:18:35 PM3/8/19
to fireba...@googlegroups.com
This should answer all your questions about running integration tests: https://github.com/firebase/firebase-admin-python/blob/master/CONTRIBUTING.md#integration-testing

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages