0

my intention is to create good rule for Firebase and friend it with my app, I started with simple one - user is authorized:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth.uid != null;
    }
  }
}

what was done to auth my app via google+Firebase:

  1. generated keystore file
  2. keystore file usage is configured in graddle so that app is signed by it
  3. SHA1 is added to Firebase
  4. new google-services.json is downloded in app folder
  5. instruction followed to auth application via google (and official one)

somehow application is going to be authorized via e-mail like:

GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        // for the requestIdToken, this is in the values.xml file that
        // is generated from your google-services.json 
        .requestIdToken(getString(R.string.default_web_client_id))
        .requestEmail()
        .build();

I believe that this .requestEmail() opens auth form in my app UI with request to enter e-mail (line comment doesn't help)...

the points are:

  1. my application is signed via keystore, and Firebase + google know that
  2. I don't need user to authorize or enter any e-mail
  3. all I need is to have my app automatically authorized for Firebase (don't care about google, but prefer usage of keystore + SHA1) so that Firebase rule will work (and later replaced with my true app uid)

What's the best/easiest approach to authorize app for Firebase and filter access in DB rule? (without any e-mail entering)

  • If you are interested in a clean Firebase authentication with Google, you can check this [article](https://medium.com/firebase-tips-tricks/how-to-create-a-clean-firebase-authentication-using-mvvm-37f9b8eb7336). – Alex Mamo May 04 '20 at 07:26
  • thank you! but it again looks like work with e-mail and needed authorization by user, which I want to be auto – Andrew Smirnov May 04 '20 at 14:48
  • yeah, looks pretty much the same as official docs, it requests user to enter e-mail+password, which I don't want. I need a solution how to authorize my application in the background without entering any e-mail – Andrew Smirnov May 04 '20 at 15:00
  • You may find assistance for advice here: https://firebase.google.com/support/troubleshooter/contact – MrTech May 25 '20 at 18:29

0 Answers0