iOS Firebase Swift: A way To Get All Users Using Auth - ios

Is there a way to get all signed up users using FirebaseAuth. I know I can create users node and save users when they sign up, but I'm looking for a way to get users using something like Auth.getAllUsers since all I'm looking for is uid and displayName. I'm using swift, so admin sdk seems not supporting it.

There is no client-side API to get a list of all users, which is why many developers write details about the users into a database (such as the Firebase Realtime Database, or Cloud Firestore).
There is a server-side Admin SDK that allows listing all users. See https://firebase.google.com/docs/auth/admin/manage-users#list_all_users

You can create a cloud function that returns the results of the Admin SDK list all users function. Make sure that you remove any private data fields from the reply, though. The hashed password, salt, and providers are included in the data.

Related

Is there a way to default disable users in a firebase authencation on signup?

I am currently developing an iOS appplication using xcode and Swift. My application works well with firebase including the function of email verification. Due to the nature of my application, I want users to be able to sign up, verify their email and then await further verification on the side of my client using firebase.
In an ideal world, firebase would have a setting that supports user being automatically disabled on signup, and you would just tick a box and the user would be enabled in the authencation page of the console.
Seeming as I am looking for my client to be able to do this, I need a way that is simple to them, so they can enable and disable accounts. There is a property in the firebase authencation page but no way to default it.
So.. My idea was to create a cloud function in firebase that automatically disables users on signup, and once my client has verified who they are they will enable them. Any ideas on what this function would look like? Disabled is a nice and easy boolean value so.
I am new to firebase, so wondering if anyone had came across this kind of issue? The link below shows the function on user creation.
https://firebase.google.com/docs/functions/auth-events#trigger_a_function_on_user_creation
You can add an Admin SDK function in the user creation event you have. See this for an example: https://firebase.google.com/docs/auth/admin/manage-users#update_a_user
The easiest way to automatically disable new user accounts is through Cloud Functions. See for an example the answer to this question about How to prevent new user registration on Firebase?.
But note that the user will already be signed in by the time the Cloud Function runs, so they'll have access until their current/initial ID token expired (up to an hour).
The proper solution is to check whether the user is verified before enabling any backend functionality. For Cloud Firestore, Cloud Storage, and Firebase Realtime Database, you can do this in their server-side security rules. See for some examples of this:
(Firebase) Firestore security rules - allow if email verified without custom tokens?
Security rule to only allow write for users with verified emails
How do I lock down Firebase Database to any user from a specific (email) domain?

How to automatically delete Firebase inactive users from database and authentication?

Even if the users are not anonymous, I would like to automatically delete the user authentication and user info in the database if they have not logged in for say, a year. This is to prevent old or spam accounts from taking up space in Firebase.
Is this possible without manually checking and deleting on the Firebase console?
You can use the Firebase Cloud Functions.
This sample do exactly what you need.
Here more samples for Firebase Cloud Functions.

Firebase multiple subaccounts per user?

I couldn't find information on this. I have an iOS app, written in swift. Firebase is my storage and database place. For now, I authenticate my users with email and password (no social media auth). My question is - is it possible after they've created their account to create many sub accounts? And if so, how do I track those (meaning, which is the primary account and how to switch between them - something like twitter and the way it allows to use multiple accounts and switch between them)?
My goal is to allow each user to have/create multiple accounts, make 1 account primary and the rest would be secondary accounts. Not sure if Firebase allows any of this though. I know this is broad description, but I want to make sure that this is indeed possible before I try to do anything like that. Any ideas?

Firebase authentication with Parse user

I'm building an iOS (Swift) app that needs realtime chat as part of the functionality. While Parse works well for push, data storage, etc..., it doesn't support realtime. I would like to use Firebase for the realtime support, but need help authenticating to Firebase using a Parse user. I really don't know where to start with this. Any help would be greatly appreciated.
The question is pretty vague so a definitive answer is not possible: here's a thought.
Firebase and Parse are two different companies and therefore require separate authentications.
If your users have a username/password type authentication in Parse, you could use the same data in Firebase and authenticate through code. i.e. User creates a new account in Parse, and an account is created in Firebase via code. When the user authenticates to Parse, it also authenticates to Firebase via code.
There are a LOT of design elements to consider in going this route: how do you create a firebase user (in code) without your app authenticating itself as a 'super' user? Hard code credentials? That may be a security issue.
Are you going to keep two sets of user data? One in Parse and one in Firebase? What if a user needs to reset their password or account. As you can see, it can get out of control rather quickly.
You may want to consider sticking with one platform to simplify the entire process. By the sound of at least one of the requirements, Firebase can do much of what Parse can do but also give the real-time updates you need.

Using fusion tables with app inventor as a database

Easy to answer question ( I hope)
Need to use fusion tables with app inventor as a database but need to have every app access it without having to log in with user id.
Does app inventor have that functionality? Believe I need to set up API for 'installed applications' but do not know where in app inventor I need to enter the SHA1 code.
App is to 'anonymously' update database without needing to log in.
Thanks in advance
I don't think that this is possible with the built-in Fusiontables Controls, see also the notes in the Pizza Party tutorial:
NOTE about Sharing Fusion Tables: To share a FusionTable with others,
you have to invite each person individually, the same way you would
share a private google doc. There is no way to share write privileges
to a FusionTable with the public. Public access is restricted to
read-only.
However this is possible with the App Inventor - Fusiontable interface using the web component. To prepare the login free access, do a run with the interface with your login and store the received refresh token as variable in your app. Then you can build your app, publish it and run the interface with the stored authorization without need to login anymore. The user will then access your fusion table with owner permissions.
See also this similar question and here
Application 1 - Using Fusion Tables like a Database*
...
In other words, if you own a Fusion Table in your own account that you
want to serve as a database in your application, you simply need to
get the access and refresh tokens for that account, and use the access
token for all requests to Fusion Tables. When the access token
expires, a 401: Unauthorized message is returned, and the refresh
token can be used to request a new access token.
...
You can then securely save the access and refresh tokens somewhere
accessible by your application, and use them in your code to make the
requests to Fusion Tables.
EDIT: You now can find a running example here.
If you just need a database for your app, also consider using Google Cloud SQL which offers familiar MySQL functionality on the cloud. https://developers.google.com/cloud-sql/

Resources