Can't import user account with CLI Firebase auth:import command

こ雲淡風輕ζ 提交于 2019-12-04 11:26:50

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

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');

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.

Thank you @wyhao31

I use PHP to get user, data and password I need to import in Firebase.

I used the hash_hmac() PHP function in a wrong way:

$secret = "helpmeplease";  
$password = "mypass";  
$hmac_md5 = hash_hmac('md5', $password, $secret);  //3a52377f6635d298436013953a1ce4dd
$base64 = base64_encode($hmac_md5); //M2E1MjM3N2Y2NjM1ZDI5ODQzNjAxMzk1M2ExY2U0ZGQ=

To fix the problem I need to force the hmac_md5 output raw binary data:

$secret = "helpmeplease";  
$password = "mypass";  
$base64 = base64_encode(hash_hmac('md5', $password, $secret, TRUE));  //OlI3f2Y10phDYBOVOhzk3Q==

So I get your result, that works correctly!

Thank you!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!