Need help with Firebase setup

I’ve been looking on similar topics for hours but nothing seems to fit my needs.

I have 2 apps. The first one is for users only (probably going to Playstore once it’s finished) and the second one is for the Admins only and will be shared as .apk file (only 4 people will have access to it).

Here’s the problem: I want the users of the first app to only be able to read the data from firebase, while the admins (who use the second app) be able to just write to the database. So basically the admins will put data to the Firebase database and the users will be able to get that data.

I have enabled sign-in as shown below (and also finished the basic firebase setup, imported the google-services.json file to both apps, added them both to firebase, added the SHA1 fingerprint etc.):

I haven’t tried the email/password sign-in method yet, I’d prefer to use Google Login instead but I can’t make it work.

These are the rules my database currently has:
I know they’re not what I’m looking for but honestly i have no idea what to put in there in order to make it work.

The screen initialization blocks are the following:
The companion result is this:

And the built apk’s result is this. It lets you pick an email but still shows you that error message:

Any ideas on how to make the authentication work and which rules to write in there? Thanks and sorry for the long post.

it is because kodular’s firebase component doesn’t have a method to get idtoken of a user. all the security rules works only if you provide the idtoken. there is one firebase extension in community which allows to get id token and won’t see this error but google sign in is not that easy in the extension. here’s the (37.8 KB)

1 Like
  1. If I use the email & password sign-in method will I still need to use that extension or will it work with Kodular’s current blocks?
  2. Is it possible to change the database rules so that the one app is only able to write and the other only to read?

yes you need to use the extension. otherwise you will get error.

you achieve that by giving the 4 admins minimal write permission in firebase. here

1 Like

Okay I’ll try using the extension but how do I get the Google ID Token :sweat_smile:

If I click “Add Member”, then add the admins’ emails and give them the proper permissions will it be fine?

first for google is id token. right now there is no way to gett google id token i also tried to search it but nobody knows thats why i said.

yes it will be fine but only give permission to people you TRUST.

vote here if you also want this firebase component to works easly

I got the Google I’d tokem and it works.
But there is a problem it only registers and unable to add gmail Id.It only adds an user in Firebase but without gmail id.

I’ve already voted. Hope it gets added some time in the future.

So basically Kodular won’t work with firebase databases that aren’t set to test mode so I need to use that extension which requires Google ID Token but can’t be obtained? If I make the users register via Email/Password will it work?

Even though the app shows an error when I choose an email to sign-in it add the user to Firebase

yes it will work with email and password.

I am not sure but you can get Google Id token here:

  • Go there and choose any api and authorize it.
  • Now exchange code for tokens.
  • And run OAuth 2.0 query.

I can not say that it will work or not.

bro you need a new id token genrated for every new user. So even if we use this method then we have to manuallly genrate id token of each user make hime sign in. which is not possible. only way to do this is at SDK Level. either we need integrate the sdk in kodular.

1 Like