0

I can’t find any Flutter documentation about how to use Google Service Account Authentication in a mobile app.

The point is to use Firestore Document Snapshot in a mobile app without prompting users for credentials. It must be Firestore Document Snapshot Listener NOT a Document Get Query because I need real time data .

Most Flutter Firestore Document Snapshot demos are without service account authentication. Other authentication demos are based on google user account credentials or third party providers such as Facebook or Github while I need app / service authentication.

1 Answer 1

2

You're not supposed to use service accounts in web and mobile apps. Since a service account is highly privileged (and always bypass security rules), it's not suitable for putting on end user devices in any form. It would be a huge security hole if a user's device contained a service account, no matter what you do to obscure that.

Service accounts are only intended for use with secure backend code. Don't try to do anything different, or you will open yourself up to a whole slew of security problems.

The only supported way of dealing with Firestore directly and securely through web and mobile apps is using Firebase Authentication. Yes, this involves making the user enter their credentials. That's a good thing - you don't want anyone to impersonate anyone else. You could look into anonymous authentication if want to create user accounts without credentials.

If you really must perform some actions with a service account, directed by a web or mobile app, the app should connect to a backend through some API endpoint. The backend can then perform the operations. If you do this, bear in mind that now people can access the API endpoint to possibly compromise your system, and that API should be controlled by some form of auth (perhaps also Firebase Auth).

Sign up to request clarification or add additional context in comments.

1 Comment

What I haven't mentioned in the description is that users already have accounts in my Website Data Base and the point is to evaluate their user access level in the DB and populate the mobile app with real time firestore content according to their user role. So at the end of the day the real solution for my problem is firebase.google.com/docs/auth/admin/create-custom-tokens . Needless to say that your post fits perfectly in to the issue description so I am going to tag your comment as the answer. Thank you for your time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.