Silas Junior
Silas Junior

Reputation: 21

How to use the same Firebase Auth for Two different Flutter apps?

I developed two different Flutter applications. An Admin Version and another Client Version. I would like to use the same login (auth) and access to Storage for both Apps.

Upvotes: 2

Views: 553

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598623

It's definitely possible to access the same Firebase project from two different apps. In fact, when these apps are locally part of the same "application", that is actually an intended use-case.

A few things to keep in mind though:

  1. Firebase Authentication does not have the concept of an administrator user. It "merely" authenticates the user, allowing them to sign in with their credentials. Any administrator logic is specific to your application, hence often referred to as an application administrator. You'll typically want to flag application administrators, for example by setting a custom claim on their accounts.

  2. Not all functionality that the application administrator may need is going to be available in Firebase's client-side SDKs. A common scenario is that the administrator should be able to create accounts for other users, where the client-side Firebase Authentication SDKs don't support this logic. For some more information on this, and how to solve it, see Firebase kicks out current user and my answer with many links here How to create firebase admin user for authentication in java. In a nutshell: you'll have to use the Firebase Admin SDK, in a trusted environment, for some of these operations.

  3. You then secure access to Cloud Storage by writing security rules. For some examples of securing access based on the user, see the documentation on securing user data.

Upvotes: 3

Related Questions