【问题标题】:Export firebase user account emails导出 firebase 用户帐户电子邮件
【发布时间】:2020-05-06 22:26:06
【问题描述】:

我在从 Firebase 导出用户帐户电子邮件时遇到问题。

我刚刚重新访问了一个几个月未接触过的旧项目,我想导出电子邮件地址。我在我的functions 文件夹中,并且已经完成:

 npm install -g firebase-tools

然后

 npm install firebase-functions

 npm install

这里没有问题。然后我输入:

firebase auth:export save_file.csv --format=csv

我得到输出:

$ firebase auth:export save_file.csv --format=csv
Exporting accounts to save_file.csv

Error: An unexpected error has occurred.

我还读到您可以尝试firebase login --interactive,但是当我这样做时,我得到了错误:

Already logged in as ***@gmail.com

我应该如何调试这个/我应该怎么做才能导出电子邮件?有什么想法吗?

谢谢。

编辑:我挖掘了firebase-debug,输出显示:

[debug] [2020-01-20T21:49:31.847Z] ----------------------------------------------------------------------
[debug] [2020-01-20T21:49:31.849Z] Command:       C:\Program Files\nodejs\node.exe C:\Users\Simon K\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js auth:export save_file.csv --format=csv
[debug] [2020-01-20T21:49:31.849Z] CLI Version:   7.12.1
[debug] [2020-01-20T21:49:31.849Z] Platform:      win32
[debug] [2020-01-20T21:49:31.849Z] Node Version:  v12.7.0
[debug] [2020-01-20T21:49:31.851Z] Time:          Mon Jan 20 2020 16:49:31 GMT-0500 (Eastern Standard Time)
[debug] [2020-01-20T21:49:31.851Z] ----------------------------------------------------------------------
[debug] [2020-01-20T21:49:31.851Z] 
[debug] [2020-01-20T21:49:31.857Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2020-01-20T21:49:31.858Z] > authorizing via signed-in user
[debug] [2020-01-20T21:49:31.859Z] [iam] checking project anonymous-social for permissions ["firebase.projects.get","firebaseauth.users.get"]
[debug] [2020-01-20T21:49:31.860Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2020-01-20T21:49:31.860Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token  
 <request body omitted>
[debug] [2020-01-20T21:49:32.050Z] <<< HTTP RESPONSE 400
[debug] [2020-01-20T21:49:32.051Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/anonymous-social:testIamPermissions  

[debug] [2020-01-20T21:49:32.183Z] <<< HTTP RESPONSE 401
[debug] [2020-01-20T21:49:32.183Z] <<< HTTP RESPONSE BODY
[debug] [2020-01-20T21:49:32.184Z] [iam] error while checking permissions, command may fail: FirebaseError: HTTP Error: 401, Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
[info] Exporting accounts to save_file.csv
[debug] [2020-01-20T21:49:32.185Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2020-01-20T21:49:32.185Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token  
 <request body omitted>
[debug] [2020-01-20T21:49:32.332Z] <<< HTTP RESPONSE 400
[debug] [2020-01-20T21:49:32.333Z] >>> HTTP REQUEST POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/downloadAccount  

[debug] [2020-01-20T21:49:32.457Z] <<< HTTP RESPONSE 401
[debug] [2020-01-20T21:49:32.457Z] <<< HTTP RESPONSE BODY
[debug] [2020-01-20T21:49:32.614Z] TypeError: Cannot read property 'code' of undefined
    at C:\Users\Simon K\AppData\Roaming\npm\node_modules\firebase-tools\lib\accountExporter.js:170:26
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
[error] 
[error] Error: An unexpected error has occurred.

这有意义吗?

【问题讨论】:

  • 尝试 npm install -g firebase-tools@latest - 您可能需要全局更新您的工具。我刚刚运行了完全相同的导出,它对我有用,所以你的脚本很好。
  • @I'mJoeToo 很遗憾对我不起作用

标签: firebase firebase-authentication firebase-cli firebase-tools


【解决方案1】:

对于任何与之苦苦挣扎的人。我最终不得不注销并重新登录到 Firebase。我认为我的令牌已过期或类似情况。

  • firebase logout

  • firebase login --interactive

由于某种原因,我不得不登录两次,但后来成功了!

【讨论】:

    【解决方案2】:

    你跑firebase use --add了吗?

    或者,您可以尝试以下任何命令吗?

    • firebase projects:list
    • firebase use project_id_or_alias
    • --projectflag.(firebase auth:export save_file.csv --format=csv --project=project_id_or_alias)

    见:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-25
      • 2017-02-23
      • 2020-11-08
      • 1970-01-01
      • 1970-01-01
      • 2015-11-01
      • 2021-06-16
      相关资源
      最近更新 更多