asked    Lorraine     2018-10-22       android       88 view        1 Answer

[SOLVED] what causes "permission denied"-message with FIREBASE and FLUTTER

I've got the error

'W/SyncTree(31625): Listen at /address failed: DatabaseError: Permission denied'

while sending a request to firebase with an anonymous firebase user and without fancy firebase database rules :) . ..and i want to find out what causes this message.

EDIT: error is the same with an existing user, means user signIn seems to work but accessing database not.

What i've done so far:

  • Set up firebase (including adding google_service.json, dependencies in pubspec.yaml) - works so far
  • creating login as follows (like in example from google link):

    Future<String> _testSignInAnonymously() async {
      final FirebaseUser user = await _auth.signInAnonymously();
      assert(user != null);
      assert(user.isAnonymous);
      assert(!user.isEmailVerified);
      assert(await user.getIdToken() != null);
      assert(user.providerData.length == 1);
      assert(user.providerData[0].providerId == 'firebase');
      assert(user.providerData[0].uid != null);
      assert(user.providerData[0].displayName != null);
      assert(user.providerData[0].photoUrl == null);
      assert(user.providerData[0].email != null);
    
      final FirebaseUser currentUser = await _auth.currentUser();
      print(currentUser.uid);
      print(currentUser.isAnonymous);
      assert(user.uid == currentUser.uid);
    
      return 'signInAnonymously succeeded: $user';
    }
    
  • the print statement provides a userId (and this id is also in firebase auth section) --> seems to me that i've got an logged in user

  • implement kind of initialization like in the google example (link):

    Future<void> main() async {
      final FirebaseApp app = await FirebaseApp.configure(
        name: 'mydbName',
        options: const FirebaseOptions(
           googleAppID: 'myAppId',
           apiKey: 'myApiKey',
           databaseURL: 'myUrl',
        ),
     );
     runApp(new MyApp(app));
    }
    
  • on another stateful widget in state i try to request some firebase data:

    void initState() {
      final FirebaseDatabase database = new FirebaseDatabase(app: widget.app);
      database.reference().child('address').once().then((DataSnapshot snapshot) {
        print('Connected to database and read ${snapshot.value}');
      });
      super.initState();
    }
    
  • i've removed all rules in firebase except:

    ".read": "auth != null",
    ".write": "auth != null",
    
  • i use an SHA-1 certificate/fingerprint in my firebase android app

  • i use the same firebase database with an firebase ios app without any problem while using anonymous users

What i need:

I need some hint how to find out if there's any problem with that initialization code or with the user login or something else

  1 Answer  

        answered    Martina     2018-10-22      

It seems the database is not correctly addressed in FirebaseApp.configure(

FirebaseDatabase.instance.reference().child(...)

would use the default database of the project configured in google-services.json





Your Answer





 2018-10-22         Honey

List UIButtons in a Grid view without using CollectionView

I'm going to have a squared grid of UIButton objects. Each of these UIButtons is referenced to an unique option and id coming from an array API.Example of the option APIoptions = ( { name = Color; "option_id" = 16; "product_option_id" = 1324; "product_option_value" = ( { image = "example.com/image.jpg"; name = red; "option_value_id" = 104; price = 0; "price_prefix" = "+"; "product_option_value_id" = 4650;...
 ios                     1 answers                     70 view
 2018-10-22         Lewis

Gridview Scroll with OnTouchListener

Basically, I want to fast select item as well as scroll Gridview. In OnItemClickListener scroll working fine but its not fast select multiple item like OnTouchListener.My code:gridView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent me) { int action = me.getActionMasked(); float currentXPosition = me.getX(); float currentYPosition = me.getY(); int position = gridView.pointToPosition((int) currentXPosition, (int) currentYPosition); switch (action) { case ...
 android                     1 answers                     71 view
 2018-10-22         Nora

Apply class on a table of GridView Yii2

I want to apply class on table generated by GridView::widget() in Yii2. <?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'mobile_number', 'email:email', 'name', 'national_id',// and so....How can I apply the CSS on the table GridView::widget()? I want to apply this:<table class="table tblSec"> You can use tableOptions property for this:<?= GridView::widget([ 'dataProvider' => $...
 gridview                     1 answers                     69 view