Firebase Authentication database interaction - firebase

Is there a way to access the "Authentication" database in Firebase?
I'm building an app which uses the Firebase anonymous authentication
I would like to access the Firebase "Authentication" database to check the last login of the user.
Tried looking through the web but didn't find any reference.
Can someone point me to the right direction please?

There is no API for you to access the timestamp of when a specific user last logged in. Most developers end up storing this type of information in their Firebase Database, for example with the structure outlined in the section structuring your database.

Firebase launched the admin node.js sdk. You can look users by uid or email and get their metadata like creation date and last login date.
https://firebase.google.com/docs/auth/admin/manage-users

Related

Flutter get User Data from Firebase

I want to get User Data from firebase, I need the diplayName of a User. is there any way to get the displayName of a other user with his uid?
There is no way to look up information about another user in Firebase Authentication by using the client-side SDKs of Firebase, as that would be a security risk.
There are two common ways to allow searching the users in a secure way:
Write information about each user to a database (such as Cloud Firestore or the Realtime Database) when they register, and then search the database when needed. That way your code controls what data gets written and thus is searchable.
Firebase has Admin SDKs that run in trusted environments, such as your development machine, a server you control, or Cloud Functions. These SDKs have options to list users, which means you can search them. If you wrap one of the Admin SDKs in a custom API that you build and secure yourself, you can then call that from your Flutter code.
Also see:
React native firebase authentication searching
You can't get the name, or any other details of a user that is not currently signed in using FirebaseAuth.
Instead, you must create a node in your database where you store the name, and any other necessary details by querying the database.

How can I see and edit the User's Additional information from Firebase consol that was edited programmatically

I am using Firebase Authentication in my app. I used method like setDisplayName in my app so that user can change the user's name himself through the app. But, the problem is that I can't access this name through my console. I can't edit it. There are simple columns in Firebase console like,
identifiers,providers,UID,Providers,Signed In.
There is no column for User Name. How can I access this information through console?
The Firebase console shows only limited information about each user profile. The rest of the information is only available when you access the profile through a Firebase API, or export the data.
Keep in mind that Firebase provides Admin SDKs, which you can run on your development machine to accomplish simple administrative tasks such as this.

How can one fetch the authorized users along with their details in Firebase

I have a Firebase project, which I'm currently using with android. I need to programmatically fetch details of the users authorized along with the UID, Email, etc. Exactly the way it is shown in firebase (with the search), this web portal will be given to the vendor or the person using it to verify the user's authenticity.
I've attached the screenshot from Firebase, I'm hoping to replicate it the same way with the search. If this is possible, how do I go about doing this?
It's not possible to list users from an Android app, using only the Firebase Authentication SDK. You can list users using the Firebase Admin SDK, but that can only be run on a backend you control, using service account credentials for your project.
It might be easier if you store user info in a database, to be queried by client code, rather than try to have your app try to access auth data directly.

Get anonymous users with Cloud Functions for Firebase

I am using Cloud Functions to manage the database and the auth in my project. I followed the example https://github.com/firebase/functions-samples/tree/master/delete-unused-accounts-cron to delete inactive users in my app. I want to get only the anonymous users that were inactive for some time. I don't know to make the query to the identity toolkit to filter only the correct ones. Does anybody help?
Thanks!
I think your best bet is to write the account auth provider(s) into your database at the time of login, then use that to further filter the set of accounts that should be deleted. This way, you won't have to take the time to query each uid to find out what its providers are.
You can use the Admin SDK listUsers API to list all users and then inspect if the account has no provider data (assuming you don't use custom authentication)/no emails and inspect the metadata lastSignInTime. However, as Firebase sessions are indefinite, that does not guarantee the account is inactive:
Listing users: https://firebase.google.com/docs/auth/admin/manage-users#list_all_users
User record metadata which contains last sign in time: https://firebase.google.com/docs/reference/admin/node/admin.auth.UserRecord#metadata

Best practice Fetch user's information from the Firebase User UID

I have integrated Firebase's Facebook and Email Login into my iOS application.
Although, I would like to only store the Firebase User ID in my API database.
Therefore from my backend server (say Ruby) how can I query firebase to get say the user's name and user's email address given that I have their Firebase User UID.
Thanks
To directly read user data for arbitrary users of your app, you'd use the Firebase Admin SDK: https://firebase.google.com/docs/admin/setup. This specific page shows how to read user data: https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data
Reading user data through the Admin SDK is currently only available for Node.js and Java. Since Ruby isn't on this list, you'll need to keep the user information elsewhere. The Firebase Database is a common place to store such data, so that any platform can access it through its REST API.

Resources