Android Firebase Auth: is "google-services.json" still required? - android

I have an Android app which uses Firebase Auth, and while fixing some issues I had, I noticed that there is no need to add the file google-services.json to the project.
My issue was the following. I perform a sign-in via Google Sign-In, and in the GSO (Google Sign-In Options) I specify
gsob.requestIdToken(".....apps.googleusercontent.com");
gsob.requestEmail();
because I want an idToken which I then can pass to the Firebase SDK in order to sign the user into Firebase (I'm using it this way for historical reasons).
It had stopped working which was the reason why I was meddling around with the google-services.json file, since I had deleted a Client-ID in console.developers.google.com and thought I made a mistake.
While being at removing stuff, I also removed an entry
<meta-data android:name="identitytoolkit.server_client_id" android:value="....apps.googleusercontent.com" />
and some more identitytoolkit metadata entries from the Manifest.
In the end the only thing that would matter was that the correct client-id is passed to gsob.requestIdToken(".....apps.googleusercontent.com");
I'm not sure if Google had some hiccups with the idTokens between Google Sing-In and Firebase during these last two days, but in the end I think I really didn't change anything to make it work again.
So the last couple of minutes I was reading through the Firebase documentation, and read that there are now two options for adding Firebase to an Android app, one is the one I used before, and then there's a new option to use the Firebase Assistant.
I never used the Firebase Assistant, but am wondering if it has been enabled automatically in my app (I never clicked "Click Connect to Firebase to register your app with an existing or new Firebase project and to automatically add the necessary files and code to your Android project.")
How can I find out if something in Android Studio has been altered to add my Firebase configuration automatically? Where do I know which client-id's it's using?
I'm asking because even the email-based authentication with Firebase (which is not using Google Sign-In explicitly) is working in the app, and there are is no json file or other client-id's in the Manifest or in the code which could be used for this.

Nothing has changed in the setup instructions. You either need to have the Play services plugin and google-server.json present, or you need to duplicate its work manually. The only ways to manually duplicate its work are to add the specific string resources to your app that it requires, or call initalizeApp with your specific settings. There are currently no alternatives.

Related

Firebase not processing analytics if the Firebase key is not present at build time

I only use Firebase for Crashlytics. The Android app needs to read the Firebase Key from a property that is not available at build time, so instead of using the default json configuration file it uses the following code which is executed during Application's onCreate() :
val builder = FirebaseOptions.Builder()
.setProjectId(firebaseProjectId)
.setApplicationId(applicationId)
.setApiKey(firebaseKey)
FirebaseApp.initializeApp(context, builder.build())
This change was made some months ago and I've noticed that the firebase analytics stopped worked since the change was published. I do receive crash reports from crashlytics but all of the other data that is grabbed automatically is not there anymore: active users, unique users, analytics events, etc.
So Crashlytics is giving very bad data because it can only take as unique users the ones that still have older versions of the app.
Am I missing additional setups for Firebase Analytics to work under these scheme?
It sounds like you might have gotten rid of the google-services.json file that you would use to integrate with Firebase. Your Firebase Analytics integration won't work without that file. You can download it again from your Firebase project and add it to the app project again.

Change Firebase project for production app with Google Authentication?

I need to change Firebase Project of production app with google authentication.
My app is working with a firebase project and a backend server from which I can force users to update my app to the latest version after login with version the user has. Because of that, I hope I can change the Firebase project where I do the authentication with Google.
I can't use old pair Package Name / SHA-1 in new Firebase project, but I can use old package name with NEW SHA-1, right?
So, users with old versions will login with old firebase project and after upgrade my app they will login with with new firebase project, right?
If so, users won't need to uninstall my app, right?
Now, how can I change the SHA-1 in Android Studio?
What I understand you are trying to do is the following.
You want to associate your app to new firebase project
You want to keep you old user base intact.
You have asked if you can change the SHA-1 of the app the answer is no without changing the signature of the app that could change everything and is not an option.
What you could do instead is use two different firebase projects in a single app and write your own logic to manage the users. You can follow this link https://firebase.googleblog.com/2016/12/working-with-multiple-firebase-projects-in-an-android-app.html here the author has explained how to go about it. you can also look up for similar solutions or arounds for the problem. Hope this helps in some way and please try to make you questions precise.
Correct me if I understood your need wrongly!
You have users and want to sign them in to a new firebase project with interrupting your current users?!
I believe what you need to use is the custom Firebase authentication
whenever the user logs in, you produce a token in you current project and pass it on to the new project.
As for:
backend server from which I can force users to update my app
you can also achieve this in firebase, hopefully the backend server is not just for this!

Firebase with dynamic applicationId

I am maintaining a website where people can customize an Android application and download as an apk file.
I need to implement push notifications. I had it implemented in Google Cloud Messaging before. But I am moving to Firebase now.
The problem is that Firebase is configured with specific application ids through google-services.json configuration file. But I need it to run with automatically generated application ids.
I have already tried to change the id in the configuration file. It compiles, but notifications are not delivered.
Please, can anyone tell me if there is a way to make it work?
Edit:
I don't see how my question is related to an Android Datepicker question with nothing to do with Firebase.
There is only one way, you need always create new android app per every unique app id in firebase console. Then download and build new app instance with generated 'json'. Unfortunately, firebase does not provide any API for automatization this, and you have to do it manually every time.

Android - firebase cloud messaging, two apps in one firebase project

I have two android applications. I am using only one firebase project for both of them, with both applications included in it. So I have only one google-services.json with specified keys for both my applications. I am trying to use firebase cloud messaging and I am experiencing following problems:
When I want to test cloud messaging from firebase console I am able to choose to which appId I want to send a message. I have both applications installed on my device. Both are working normally. I have also released them to google play (alpha testing) and everything went well. I am able to download them from store normally. AppId should be set properly (how can I check that?). Problem is, that when I choose the first app in firebase console I am receiving notifications from both apps and when I choose the second app I am receiving nothing.
What can cause these problems? Do I need to create completely new firebase project for the second app, too? Or am I missing something?
If you need to see some code, let me know. At this point I don't know what piece of code could tell you more about my problem.
It looks like you have used same google service json file on both your apps. So thats why sending cloud notification for one app is received on both apps while in second case since no app has the json file for that there is no notification.
Go to your firebase project settings and download the google services file for both app ( you should first download one and move that file to desired project then download second services file).

How can I restore login functionality at Firebase after integrating with Google?

I am developing an Android App using Firebase. I had everything running fine up to this morning. I went to Firebase, imported the project at their new console and then I tried to add Analytics to my app.
At this point I couldn't use Google login, and I guess it was because adding Analytics I skipped to add my SHA-1 key, so the newest information at Google was that I didn't have a SHA-1 key. I didn't see that I had to whitelist my Google app which was actually login in people in my app, and that was a big mistake. Trying to solve it I begun to change things, so many that I couldn't even list them here. A short version could be:
I updated the Android SKD Manager.
I changed the dependencies for Gradle. Still not working.
I saw that I could give my SHA-1 key to Firebase, but I had a alert saying that this key was already in use by another App (the one at Google API)
In order to solve it, I deleted the credentials of my Google API App -not so good idea-
Then I used my SHA-1 key at Firebase. Still not working.
I tried to put everything as it was at the beginning, but now I cannot delete my key from Firebase. What I've done is write a random key to be able to use it at Google API.
I went to Google API and created a new credential for the App that I was using and was working fine up to this morning.
I whitelisted the App ID at my Firebase Auth settings. Still not working
Surely I have done other stuff but I don't even remember.
Now I have the following error when I try to login with Google, but also with Facebook(?!), and I haven't tried with other providers. The error says:
FirebaseLoginError = PROVIDER_NOT_ENABLED: Make sure google login is enabled and configured in your Firebase. (FirebaseError: Invalid authentication credentials provided.)
There are so many things that could lead to a problem that I have been trying to fix it during all the morning and I am still completely lost.
What should I do to restore everything as it was?

Categories

Resources