Firebase Auth - not working

Dear AppGyver Team,

first: great job on your video how to connect Firebase: Google Firebase connector - Composer

The Todo data base example worked right away!

But the Authentication always tells me that my entered data is wrong. I really don’t know what I could have missed as the steps are very easy: enable auth in firebase for email/pw → create a user → enable auth in composer → test it… :frowning:

If you have any idea what I missed I would be very thankful… I will try the next days to do it maybe all from scratch but as the ToDo list works very well I assume I have setup all correct…

Thanks
Jens

1 Like

Hi Jens, glad to hear you liked the tutorial! Looks like there is in fact something wrong with the Firebase auth, I wasn’t able to get it working either. I’ll report the issue forward, thanks for reaching out!

1 Like

Having the same issue. Glad I checked here after only an hour of trying to troubleshoot :grimacing:

Based on experimenting with my Firestore security rules, it seems that AppGyver is successfully communicating to Firebase Auth that I am authenticated (“request.auth != null” passes), but not communicating which username I’m authenticated under (any rules that match usernames fail with error 403).

@Jens_Limbach, did you also configure the Web app? I had forgot to fill in the web app name and API key, which resulted in the auth not working in the preview.

@escapenewhaven – what does your Firebase security rule look like?

@Mari I’m using the exact set of rules that they use in the second example here.

My setup is very simple: the user authenticates, then can access the document in the “users” collection that corresponds to their username. I am passing their username via variable into the document identifier and it seems to be resolving in the correct URL for the GET request. Unfortunately no matter what I try I keep getting a 403 permission error – unless I simplify the rules to allow all authenticated users to access everything (the commented-out lines in the rules screenshot), which works for testing most parts of the app but is not going to work in production.

I am building with 2.8.33.


Screen Shot 2021-07-30 at 3.47.04 AM
Screen Shot 2021-07-30 at 3.46.27 AM

When I run the same operation in the Rules Playground, it is successful.

Looks like uid in this case is a Firebase assigned id to the user (if you check on the Authentication tab, each user has an UID that is a string), but your custom collection “users” is using email as record identifier. So when you have a rule like

allow read, write: if request.auth != null && request.auth.uid == userId;

the request.auth.uid is a string, but it’s getting compared to an email.

Would it work if you try to update the rule to

allow read, write: if request.auth != null && request.auth.token.email == userId; ?

2 Likes

You are 100% right :crazy_face:

1 Like

Hi, how did you connect the user UID or email to firestore?

@Mari : Thank you so much! It immediatly worked after adding the web app details in the AppGyver configuration for firebase! Thank you so much for you super fast help! :slight_smile: :slight_smile:

@Mari : It works now on the Web App. But the iOS Preview App crashes now the moment I open it. When I remove the Auth its working again… Any ideas?

Hi @Jens_Limbach , have you configured the iOS app?

1 Like

Dear @Mari , I am so sorry it was also here my mistake… I switched the app id and the client id… For sure it cannot work… Thanks for asking exactly the right questions! It is now all working fine! :slight_smile:

1 Like