无法使用CLI Firebase auth:import命令导入用户帐户 [英] Can't import user account with CLI Firebase auth:import command

查看:74
本文介绍了无法使用CLI Firebase auth:import命令导入用户帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Firebase中导入带有电子邮件和密码的用户列表.

I need to import a list of users, with email and password, in Firebase.

我正在尝试使用CLI auth:import命令在Firebase中导入用户. ( https://firebase.google.com/docs/cli/auth-import)

I'm trying to import users in Firebase using the CLI auth:import command. (https://firebase.google.com/docs/cli/auth-import)

我选择了 HMAC_MD5 哈希算法

我正在使用 helpmeplease 作为加密的秘密字符串->在Base64中成为 aGVscG1lcGxlYXNl

I'm using helpmeplease as secret string for encritption -> in Base64 becames aGVscG1lcGxlYXNl

我正在使用 mypass 作为测试密码:用HMAC_MD5和秘密的"helpmeplease"进行了加密,它变成了 3a52377f6635d298436013953a1ce4dd ,而在Bas64中变成了 M2E1MjM3N2Y2NjM1ZDI5ODQzN2M =

I'm using mypass as a test password: crypted with HMAC_MD5 and secret "helpmeplease" it becames 3a52377f6635d298436013953a1ce4dd and in Bas64 becames M2E1MjM3N2Y2NjM1ZDI5ODQzNjAxMzk1M2ExY2U0ZGQ=

我正在使用users.json

I'm using a users.json

  {    "users": [ 

    { 

      "localId": "9997", 

      "email": "test@test.com", 

      "passwordHash": "M2E1MjM3N2Y2NjM1ZDI5ODQzNjAxMzk1M2ExY2U0ZGQ=", 

      "displayName": "9997", 

    }

  ]  }

我使用以下命令:

**firebase auth:import --hash-algo='HMAC_MD5' --hash-key='aGVscG1lcGxlYXNl' --project='my-project-name-test' users.json** 

结果是:

处理users.json(194字节)

开始导入1个帐户.

成功导入.

,并且该用户被导入到users数据库中.

and the user is imported in the users database.

但是..当我尝试使用 auth().signInWithEmailAndPassword('test@test.com','mypass') ..我收到此错误:

BUT .. when I try to login using the auth().signInWithEmailAndPassword('test@test.com', 'mypass') .. I get this error:

{[错误:密码无效或用户没有密码.] 代码:"auth/wrong-password",

{ [Error: The password is invalid or the user does not have a password.] code: 'auth/wrong-password',

消息:密码无效或用户没有密码." }

message: 'The password is invalid or the user does not have a password.' }

我不知道怎么了..你能帮我吗?

I can't figure out what's wrong.. Can you help me?

谢谢

推荐答案

您的密码哈希似乎不正确.您能否指出如何生成HMAC_MD5哈希?

It seems that your password hash is not correct. Could you point out how do you generate HMAC_MD5 hash?

我使用以下NodeJS代码片段创建HMAC_MD5密码哈希.

I use the following NodeJS code snippet to create HMAC_MD5 password hash.

var crypto = require('crypto');
crypto.createHmac('md5', 'helpmeplease').update('mypass').digest().toString('base64');

结果是"OlI3f2Y10phDYBOVOhzk3Q ==.然后,我在您的帖子中使用命令将用户导入Firebase Auth.我确认可以成功登录.

And I get "OlI3f2Y10phDYBOVOhzk3Q==" as a result. Then I use the command in your post to import user to Firebase Auth. I verified I can sign in successfully.

这篇关于无法使用CLI Firebase auth:import命令导入用户帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆