Permission denied issue with new Firebase.

24,020 views
Skip to first unread message

James Laurenstin

unread,
May 24, 2016, 11:59:40 AM5/24/16
to Firebase Google Group
Hi, 

I'm having problem setting up our iOS project (which is used in stores) with the new Firebase.

I've added and setup GoogleService-Info.plist file

Called FIRApp.configure() in the  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {}

But unfortunately, I'm getting a Permission denied error when I'm trying to check a database value.

Any ideas of that I'm doing wrong?

Firebase structure:
// mfind-dev 
    ---> stores
    ---> sessions
    ---> employees


self.serverRef.child("stores").observeEventType(.Value, withBlock: { snapshot in

                //  value successfully checked

            }, withCancelBlock: { error in

                // error, permission denied.

        })



Frank van Puffelen

unread,
May 24, 2016, 12:05:06 PM5/24/16
to Firebase Google Group
Hey James,

Most likely this is because the Database of projects created in the new Firebase Console are readable/writeable only by users that are signed in using Firebase Authentication. Since you're not signing the user in from your code, the database denies you access to the data.


The simplest workaround for the moment is to go into the Database panel in the console for you project, select the Rules tab and replace the contents with these rules:

{
  "rules": {
    ".read": true,
    ".write": true
  }
}

This makes your new database readable and writeable by everyone. Be certain to secure your database again before you go into production, otherwise somebody is likely to start abusing it.


See the quickstart for the Firebase Database security rules.


    puf

James Laurenstin

unread,
May 24, 2016, 1:32:24 PM5/24/16
to Firebase Google Group
Yes, it worked for now. Thanks

Frank van Puffelen

unread,
May 24, 2016, 2:54:37 PM5/24/16
to Firebase Google Group
Great to hear. 
Once you've gone through the initial steps of reading/writing to your database, I highly recommend that you implement Firebase Authentication and reset the security rules to their default state.

James Laurenstin

unread,
May 24, 2016, 5:38:19 PM5/24/16
to fireba...@googlegroups.com
Yes, that sounds like a good idea. Ever since I've migrated to the new Firebase it was giving me those issues.

For now, I'll reset the security rules.

Thanks a lot.

- James

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/oXyspJwlgU0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/e1609740-713e-4140-96a6-15f6c22cfead%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Sudharsan R

unread,
Jun 2, 2016, 3:43:23 PM6/2/16
to Firebase Google Group
I am trying to hit the database using the access_token as per the REST API documentation. But I get the error as follows. Any help is appreciated.

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    37  100    37    0     0     56      0 --:--:-- --:--:-- --:--:--    56{
  "error" : "Permission denied."
}

Security rule:
{
  "rules": {
    ".read": "auth !== null",
    ".write": true 
  }
}
Message has been deleted

Sudharsan R

unread,
Jun 2, 2016, 5:39:24 PM6/2/16
to Firebase Google Group
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    37  100    37    0     0     56      0 --:--:-- --:--:-- --:--:--    56{
  "error" : "Permission denied."
}

Posted with the actual database name and token.

On Thursday, 2 June 2016 15:27:03 UTC-6, Jacob Wenger wrote:
That access token looks malformed. You can verify this by inspecting the decoded token on jwt.io. Are you sure you copied the entirety of it?

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Jacob Wenger

unread,
Jun 2, 2016, 5:40:51 PM6/2/16
to Firebase Google Group
Hey  Sudharsan,

Would you mind starting a new thread instead of tagging onto a tangentially related one? Please provide answers to the following questions so we can more easily help you:
  • How did you generate the access token you are using?
  • How old was the access token? FYI that they expire after one hour.
Please provide the link to the other thread here so that people can follow the conversation.

Jacob

Sudharsan R

unread,
Jun 2, 2016, 6:58:16 PM6/2/16
to Firebase Google Group
Sure I am doing it now! Thanks for your help.

Sudharsan R

unread,
Jun 2, 2016, 8:06:22 PM6/2/16
to Firebase Google Group
Pls follow the step by step reproduction here -> https://groups.google.com/d/msg/firebase-talk/s0wtW8wCwl8/D7NibHWKAwAJ
Reply all
Reply to author
Forward
0 new messages