FirebaseAuthInvalidUserException after Firebase authentication migration - android

TL; DR
Is it possible the same Android app authenticate on both legacy and latest Firebase?
Description
We are refactoring an Android app that stills rely on legacy Firebase framework to the latest version of Google Firebase.
Unfortunately we have to authenticate on both framework versions calling simultaneously:
FirebaseAuth.signInWithEmailAndPassword
Firebase.authWithPassword
Even though the email/password works on the legacy API, the following error is thrown by the latest one:
com.google.firebase.auth.FirebaseAuthInvalidUserException:
There is no user record corresponding to this identifier.
The user may have been deleted.
at com.google.android.gms.internal.zzblv.zzce(Unknown Source)
at com.google.android.gms.internal.zzbls$zzj.zza(Unknown Source)
at com.google.android.gms.internal.zzbmd.zzcf(Unknown Source)
at com.google.android.gms.internal.zzbmd$zza.onFailure(Unknown Source)
at com.google.android.gms.internal.zzbly$zza.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:453)
So does it means it is not possible the same Android app authenticate on both legacy and latest Firebase?

Related

AbstractCommandTask: Exception occurred while processing task: com.amazon.a.a.n.a.a.a: AUTH_TOKEN_VERIFICATION_FAILURE: null: null

I was using for Amazon In-App Purchases (IAP) in-app-purchasing-2.0.76.jar and switched to com.amazon.device:amazon-appstore-sdk:3.0.2 after their latest update. I followed the instructions provided by Amazon for the migration to AppstoreSDK.
I also followed the updated instructions for AppTester as described here.
But, I receive an Authentication Exception:
D/Kiwi: AbstractCommandTask: Exception occurred while processing task: com.amazon.a.a.n.a.a.a: AUTH_TOKEN_VERIFICATION_FAILURE: null: null
com.amazon.a.a.n.a.a.a: AUTH_TOKEN_VERIFICATION_FAILURE: null: null
at com.amazon.a.a.n.a.b.a(AuthenticationTokenVerifier.java:94)
at com.amazon.a.a.n.a.a.a(AbstractCommandTask.java:204)
at com.amazon.a.a.n.a.a.a(AbstractCommandTask.java:131)
at com.amazon.a.a.n.b.b$1.run(SimpleTaskPipeline.java:179)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
Thus, the listener for methods: PurchasingService.getUserData(); and PurchasingService.getPurchaseUpdates(true); is not triggered.
Tried and failed:
Update ProGuard for possible obfuscation in Amazon classes.
Remove V2 signing for debug .apk.
Ensure that I am in Sandbox Mode.
Update AppstoreAuthenticationKey.pem file from Amazon Developer Console.
Update amazon.sdktester.json file from Amazon Developer Console.
Compare existing code with the documentation provided by Amazon.
Note: The exact same implementation with in-app-purchasing-2.0.76.jar was working.
All the above were tested in Amazon Kindle Fire HD 10 tablet running Fire OS 7.3.2.2
Any thoughts?
As you mention the Amazon App Tester app, I presume you receive the AUTH error during local testing.
If so, check your final merged AndroidManifest.xml contains the receiver tags needed for the Amazon App Tester to respond to your sandbox API requests:
https://developer.amazon.com/docs/in-app-purchasing/iap-implement-iap.html#responsereceiver
I had the same issue using build flavours (one for Google, one for Amazon) and the receiver tags were being ignored in the Amazon manifest.

This app is not authorized to use Firebase Authentication

I am getting this error when using Firebase mobile authentication on my physical device.
Looking for solutions I did the following:
1.Updated SHA1 in firebase console
2.I am using firebase Api and android N
3.I checked for play store updates and it shows that it is the latest version
Note: I am not using a emulator but a real device and it still is not working.
02-25 11:25:23.430 13164-13164/com.odetion.odetion W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms
02-25 11:25:24.077 13164-13164/com.odetion.odetion W/OtpVerificationActivity: onVerificationFailed
com.google.firebase.auth.FirebaseAuthException: This app is not authorized to use Firebase Authentication. Please verifythat the correct package name and SHA-1 are configured in the Firebase Console. [ App validation failed ]
at com.google.android.gms.internal.zzdxm.zzao(Unknown Source)
at com.google.android.gms.internal.zzdye.zza(Unknown Source)
at com.google.android.gms.internal.zzdyf.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6165)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
As you error says:
Please verifythat the correct package name and SHA-1 are configured in the Firebase Console.
So the problem is either your package name isn't correct or either your SHA-1. Make sure both are correct and try again.

Cannot find GOOGLE appId for project : <projectid>

I'm implementing google authentication on firebase using the firebaseui lib.
Firebase is working properly, i can access the data in my database, and email/password auth is also working, although when i try to login using google i always get the same error :
W/AuthMethodPicker: Firebase sign in with credential unsuccessful
com.google.firebase.FirebaseException: An internal error has occured. [ Cannot find GOOGLE appId for project: 12345678. ]
at com.google.android.gms.internal.zzafg.zzes(Unknown Source)
at com.google.android.gms.internal.zzafd$zzg.zza(Unknown Source)
at com.google.android.gms.internal.zzafo.zzet(Unknown Source)
at com.google.android.gms.internal.zzafo$zza.onFailure(Unknown Source)
at com.google.android.gms.internal.zzafj$zza.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:453)
i know that this value is extracted from the json file and added as a resource property during build by com.google.gms.google-services plugin, so i checked and the property was in fact added but for some reason it seems that firebase is not able to read it at runtime..
Any idea about what i can be doing wrong?
thanks!
Before you generated your app's google-services.json, did you enable Google Sign In for your project?
https://developers.google.com/identity/sign-in/android/start-integrating
Make sure you have a Firebase project
In that project make sure you have enabled GOOGLE AUTHENTICATION
Now Download a fresh copy of the google-services.json and replace it with the old one inside your app folder
yes i enabled google auth before generating the json.
Another detail is descovered in the meantime if that google auth does work without firebase-ui.
What i did was to try their example of google auth (adding to my app source) and it worked without issues.
Adding firebase-ui seems to remove the need for some extra logic so i wanted to use it, but it seems i'm either missing something or there is a bug on firebase-ui .
Leaving this here for anyone that might encounter this issue now.
Had a similar problem to above only difference is i had it on iOS. Would try to launch and sign in through google and would get the same internal error.
What worked for me was enabling the identity kit on google API and then checking "Google" and the other providers I used. You can find this on the google cloud console -> API Manager -> Dashboard.
App restart, clean build and then everything worked.

Firebase NullPointerException in Play Services 9.2.1

I updated Google Play Services in my app from 8.4.0 to 9.2.1 and started seeing the following crash coming in multiple times per day:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] java.lang.String.getBytes()' on a null object reference
at android.util.Base64.decode(Base64.java:118)
at com.google.firebase.iid.zzg.zzkl(Unknown Source)
at com.google.firebase.iid.zzg.zzh(Unknown Source)
at com.google.firebase.iid.zzd.zzb(Unknown Source)
at com.google.firebase.iid.zzd.zzcxa(Unknown Source)
at com.google.firebase.iid.zzd.zzbmu(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.zzcww(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceIdService.zzaa(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceIdService.zzm(Unknown Source)
at com.google.firebase.iid.zzb$2.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
I am not explicitly including Firebase nor have I migrated from GCM yet, but I do have google services in my app. I think Firebase coming in through a dependency of my other play-services integrations or the google-services plugin. Here's a snippet of my build.gradle file:
compile 'com.google.android.gms:play-services-analytics:9.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.2.1'
compile 'com.google.android.gms:play-services-places:9.2.1'
compile 'com.google.android.gms:play-services-gcm:9.2.1'
This crash seems very similar to this one but it's coming from getInstance() rather than getToken() so I'm wondering if anyone knows if I'm missing an integration or something like that? I'm hoping that the only answer isn't to wait for google to fix.
UPDATE: I added Firebase to my app through the dashboard, then generated a new google-services.json file, repackaged my app and released a patch. This did not seem to fix the problem, as I am still seeing occurrences in Crashlytics in the new version.
UPDATE 2: I still haven't found a solution, but I've noticed that these crashes are tapering off in Crashlytics. I had 40 the first day, 30 the second day, 10 the third day, and now down to ~4. This leads me to believe that this bug only affects new users or updating users, of which there were a lot initially as my users' apps upgraded to the new version. I still think this is a bug on Google's end and hope they will fix, but at least it's not as widespread as I initially thought.
As described in my updates, after a few days I saw fewer and fewer of these errors, until now a few weeks later I'm not seeing them at all anymore. So I guess the answer is that this intermittently affects users that are updating their apps, and eventually dies down on its own. Most likely no action is needed on the developer's part.

Android Firebase DynamiteModule: Failed to load module descriptor

Since upgrading to the newest version of Firebase (9.0.0), I can't get rid of the following two errors when authenticating a user through signInWithEmailAndPassword(). Does anyone have an idea what's going on?
05-19 18:09:49.245 23550-23589/[PACKAGE] E/DynamiteModule: Failed to load
module descriptor class: Didn't find class
"com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor"
on path: DexPathList[[zip file
"/data/app/[PACKAGE]-3/base.apk"],nativeLibraryDirectories=
[/data/app/[PACKAGE]-3/lib/x86, /vendor/lib, /system/lib]]
And
05-19 18:09:49.252 23550-23550/[PACKAGE] E/FirebaseApp: Firebase API
initialization failure.java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
(...)
Caused by: java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'com.google.firebase.iid.zzg' appears in /data/data/[PACKAGE]/files/instant-run/dex/slice-com.google.firebase-firebase-iid-9.0.0_95503dc60ed409569d1585da411de93e6c633bf7-classes.dex)
at com.google.firebase.iid.zzg.zzeC(Unknown Source)
at com.google.firebase.iid.zzg.<init>(Unknown Source)
at com.google.firebase.iid.zzg.<init>(Unknown Source)
at com.google.firebase.iid.zzd.zzb(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method) 
at com.google.firebase.FirebaseApp.zza(Unknown Source) 
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) 
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) 
at com.google.firebase.FirebaseApp.zzbu(Unknown Source) 
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723) 
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
(...)
I had the same problem and I found a mistake done by me in my Firebase console.
One of the reason for this problem could be, your Sign In Method inside Firebase > Auth Dashboard might be disabled.
I just enabled it and it started working.
Can you check your Google Play Services version?
From Firebase oficial website:
Prerequisites
An Android device running Google Play services 9.0.0 or later
The Google Play services SDK from the Android SDK Manager
Android Studio 1.5 or higher
An Android Studio project and its package name.
Very sad that Firebase initialization errors are so not straightforward, so developers need to guess what went wrong. In my case I imported only:
compile 'com.google.firebase:firebase-auth:10.2.0'
and forgot to import also core:
compile 'com.google.firebase:firebase-core:10.2.0'
Maybe it will help someone, good luck!
I found the issue. The issue was the first prerequisite Guilherme mentioned, but not the boldfaced part.. Although your dependencies also need to explicitly state 9.+ of the play services part, the devices itself also needs to have 9.+ installed. Debugging on my phone works fine and updating the image of my emulator solves the issue there as well.
Disabling Instant Run worked for me. Sounds ridiculous, I know. I tried cleaning the project. I tried uninstalling/reinstalling the app. The thing that finally did the trick was disabling Instant Run. sigh
I logged out and then logged in and it solved this problem for me.
Probably from some kind of synchronization the FB stuff have not implemented.
If this problem consist I will try to intercept it. But reallly, this is a bug in Firebase system. And It is a bug that is caused by more than one use case, which is another issue on its own.
You can check out while adding google sign in option
Before we use
GoogleSignInOptions gso = new GoogleSignInOptions
.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
add one line as show in the following code
GoogleSignInOptions gso = new GoogleSignInOptions
.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
after adding this if you get the error like
An internal error has occured. [ Invalid Idp Response: id_token audience mismatch. ]
then Click here to get solution this works for me.
If you just want to use the Firebase authentication and you got here because of the error:
Didn't find class
"com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor"
Go to https://console.firebase.google.com/project/[your project]/authentication/providers and enable the authentication providers you support.
I had similar issue with signup the user but finally found a working solution.
Uninstall the HAXM and reinstall it solves my issue and it successfully signup's the user to firebase auth :)
This answer on another question made my app authenticate
Alfonso Gomez Jordana Manas
Hello Pierre,
You have to manually whitelist your existing Google OAuth 2.0 client IDs in the Firebase console before using it with the new Auth APIs.
In order to do so, follow these steps:
Go to the Credentials section in the Google API Console.
Select from the top right corner the project where you had previously configured Google Sign-In.
Go to the OAuth 2.0 client IDs section
If you are using Google Sign-In on Android or iOS applications:
Take note of the Client ID string corresponding to all the entries registered for your applications.
Input these Client IDs into your Firebase project’s configuration:
Go to the Firebase console at https://console.firebase.google.com
Open the Auth section
Under Sign-In methods, open the Google configuration, and add all your client IDs to the whitelist of client IDs from external projects.
If you are using Google Sign-In on a web application:
Click to open your web client ID and take note of both the client ID and secret.
Input this Client ID into your Firebase project’s configuration:
Go to the Firebase console at https://console.firebase.google.com
Open the Auth section
Under Sign-In methods, open the Google configuration, and add the values under the Web SDK configuration section.
Let me know if this resolves your issue.
if you do everything but you got nothing try to update your ARM EABI.
Google APIs ARM EABI v7a System Image
If your emulator has not new goggle updates you will get always auth error.
Do everything suggested in this post then update ARM EABI image.
This solved my problem.
It may also happen when you don't have the SHA1 fingerprints registered in Firebase and in Google API. There in both of them must register two fingerprints: from the debug keystore and from the production keystore (generated when you create the project's apk for the first time when you enter some password keys on Android Studio).
Here shows how to get the SHA1 from there.
or run this command on C:\Users\<user name>\.android directory.
keytool -list -v -keystore debug.keystore
Sharing my experience:
I faced the same issue, I googled everywhere but couldn't find the exact answer, even if I was doing everything as documented by Google Android documentation. Suddenly after a day, my app was working fine and at that same moment I got the email from google stating "Google APIs Explorer connected to your Google Account". And it looks to me that google takes time to grant us access, just wait for this email, maybe this issue is not related to bad code.

Categories

Resources