首页 > 解决方案 > 我可以将 auth:import 和 auth:export 工具与 Firebase Auth Emulator 一起使用吗?

问题描述

我想在 firebase auth 模拟器启动时使用我的测试用户帐户预加载它,就像我为 Firestore 模拟器及其导入/导出选项所做的那样。我在模拟器运行时尝试使用 auth:import 和 auth:export,但它连接到我们实际的开发 firebase 项目,而不是模拟器。无论如何要针对身份验证模拟器运行 auth:import 和 auth:export 吗?

作为参考,我指的是这些命令(https://firebase.google.com/docs/cli/auth)和这个模拟器(https://firebase.google.com/docs/emulator-suite/connect_auth)。

标签: firebasefirebase-authenticationfirebase-tools

解决方案


执行此操作的功能现已添加到 firebase 工具中

较旧的答案仍然有效并且可能有用

https://github.com/firebase/firebase-tools/releases/tag/v9.1.0

支持模拟器:Auth Emulator (#2955) 的导出和导入。

https://github.com/firebase/firebase-tools/pull/2955

firebase help auth:import
Usage: firebase auth:import [options] [dataFile]

import users into your Firebase project from a data file(.csv or .json)

Options:
  --hash-algo <hashAlgo>               specify the hash algorithm used in password for these accounts
  --hash-key <hashKey>                 specify the key used in hash algorithm
  --salt-separator <saltSeparator>     specify the salt separator which will be appended to salt when verifying password. only used by SCRYPT now.
  --rounds <rounds>                    specify how many rounds for hash calculation.
  --mem-cost <memCost>                 specify the memory cost for firebase scrypt, or cpu/memory cost for standard scrypt
  --parallelization <parallelization>  specify the parallelization for standard scrypt.
  --block-size <blockSize>             specify the block size (normally is 8) for standard scrypt.
  --dk-len <dkLen>                     specify derived key length for standard scrypt.
  --hash-input-order <hashInputOrder>  specify the order of password and salt. Possible values are SALT_FIRST and PASSWORD_FIRST. MD5, SHA1, SHA256, SHA512, HMAC_MD5, HMAC_SHA1, HMAC_SHA256, HMAC_SHA512 support this flag.
  -h, --help                           output usage information

推荐阅读