Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Auth Logs - GCP

Is possible to retrieve the logs about when a user is log-in or log-out to the platform? And also send them to stackdriver as Cloud Functions logs? thanks

like image 718
Marco Predari Avatar asked Jan 28 '23 00:01

Marco Predari


2 Answers

You can enable Activity Logging for Firebase Authentication using the REST API. Those docs enable logging for the Identity Toolkit API (identitytoolkit.googleapis.com) which is used by both Firebase Authentication and Google Cloud Identity Platform.

One of the easier ways for you to retrieve the auth token for the REST command is to have a project owner use OAuthPlayground and authorize the Identity Toolkit API v3 scopes

Identity Toolkit API v3 scopes

After enabling Activity Logging you will be able to view these logged operations in Google Cloud Logging (StackDriver). Now you will be able to see successful and unsuccessful login requests e.g. SignInWithPassword for email+password auth and SignInWithIdp for federated sign-in requests like Google SignIn. One way to view requests for a specific user you could filter the logs to only include a specific jsonPayload.response.email

NOTE: Enabling Activity Logging will not enable Google Cloud Identity Platform for the project, so your project will continue to be subject to Firebase Auth Billing and not Google Cloud Identity Platform Billing.

One thing to be aware of is that if you have a large number of users, or really significant activity on your project, you might also want to specify exclusions to minimize cost/traffic/noise.

like image 65
Thomas Burke Avatar answered Feb 05 '23 07:02

Thomas Burke


Is possible to retrieve the logs about when a user is log-in or log-out to the platform?

Unfortunately, Firebase does not provide such informations. To solve this, you should create your own mechanism to keep track of users log-in and log-out.

like image 23
Alex Mamo Avatar answered Feb 05 '23 05:02

Alex Mamo