Firebase身份验证日志-GCP

时间:2018-12-13 13:18:34

标签: firebase google-cloud-platform firebase-authentication google-cloud-firestore google-cloud-stackdriver

是否可以检索有关用户何时登录或登出平台的日志?还将它们作为Cloud Functions日志发送到stackdriver吗? 谢谢

2 个答案:

答案 0 :(得分:2)

  

是否可以检索有关用户登录或登出平台的日志?

不幸的是,Firebase不提供此类信息。为了解决这个问题,您应该创建自己的机制来跟踪用户的登录和注销。

答案 1 :(得分:2)

您可以使用 REST API 为 Firebase 身份验证启用 Activity Logging。这些文档为 Firebase 身份验证和 Google Cloud Identity Platform 使用的 Identity Toolkit API (identitytoolkit.googleapis.com) 启用日志记录。

为 REST 检索身份验证令牌的一种更简单的方法 命令是让项目所有者使用 OAuthPlayground 并授权 这 Identity Toolkit API v3 范围

Identity Toolkit API v3 scopes

启用活动日志后,您将能够在 Google Cloud Logging (StackDriver) 中查看 these logged operations。现在您将能够看到成功和不成功的登录请求,例如SignInWithPassword 用于电子邮件+密码身份验证,SignInWithIdp 用于联合登录请求,例如 Google SignIn。查看特定用户请求的一种方法,您可以过滤日志以仅包含特定的 jsonPayload.response.email

注意:启用 Activity Logging不会为项目启用 Google Cloud Identity Platform,因此您的项目将继续受 Firebase Auth Billing而不是Google Cloud Identity Platform Billing

需要注意的一件事是,如果您的项目有大量用户或非常重要的活动,您可能还希望specify exclusions最大限度地降低成本/流量/噪音。

相关问题