导出 firebase 用户帐户电子邮件

Export firebase user account emails

我在从 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

我应该如何调试 this/what 我应该如何导出电子邮件?有什么想法吗?

谢谢。

编辑:我深入研究了 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.

这有意义吗?

你 运行 firebase use --add 了吗?

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

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

参见:

献给任何遇到同样问题的人。我最终不得不注销并重新登录到 firebase。我认为我的令牌已过期或类似情况。

  • firebase logout

  • firebase login --interactive

出于某种原因我不得不登录两次,但它成功了!