NativeScript Firebase Google Authentication - android

I am using NativeScript (Vue app) with the Firebase plugin to allow Google account logins.
The login button redirects to Google sign-in page but I cannot sign in. The error displayed is "This account already exists on your phone."
According to the plugin page this will happen if the SHA1 fingerprints have not been uploaded to the Firebase console.
There is no difference between a physical device or the emulator, neither between "tns run" and "tns build" and then uploading the APK manually.
The command I use is
tns run android --key-store-path ./keyStore.jks --key-store-password <my_keystore_password> --key-store-alias <my_alias> --key-store-alias-password <my_alias_password> --bundle
I followed these steps:
Used keytool to get the SHA1 and added it to the Firebase
console.
Downloaded the google-services.json file and added
it to the app/App_Resources/Android folder.
Used apksigner to
verify the SHA1 and it matches what I have in the Firebase console
as well as the keystore.
When I check the Firebase Analytics page I can see the connection, so I am using the correct app URI etc.
The following is printed in the terminal window:
JS: 'Make sure you\'ve uploaded your SHA1 fingerprint(s) to the Firebase console. Status: Status{statusCode=unknown status code: 12502, resolution=null}'
JS: 'Has the SHA1 fingerprint been uploaded? Sign-in status: Status{statusCode=unknown status code: 12502, resolution=null}'
I noticed another question regarding this on SO but it's not been answered and is a few years old.
Any suggestions/help would be greatly appreciated.

Something that worked for me was to delete the "Platforms" directory from the project files and then run tns build android --bundle.
I would also just verify that your SHA1 fingerprint that you can find with:
keytool -exportcert -list -v \
-alias androiddebugkey -keystore ~/.android/debug.keystore
is the same as one listed in your Firebase settings. (https://developers.google.com/android/guides/client-auth)
The other thing to check would be that you downloaded the google-services.json file after you added the SHA1 fingerprint. But it seems like you've already done most of that.

You have to provide yet another SHA-1 fingerprint.
Locate your debug.keystore (usually in %USERPROFILE%.android\debug.keystore).
Use keytool to retrieve key information as you did with your upload keystore.
Put retrieved SHA-1 into firebase authentication console.
That's all folks.

Related

Something went wrong with Google Auth only on Android

My firebase authentication used to work smoothly on my IONIC app on both iOS and Android.
Testing on Android after quite a few changes working on IOS side, I can no longer make a google login, though it still works well on iOS it gives me this on Android.
I already checked my SHA1 and SHA256 configuration in firebase console.
Loging in with google also works on a web browser. It only fails on Android.
Any suggestion is welcome.
I had the same problem in the Ionic Capacitor for android version...
Check if your SKD was automatically updated...
I don't know why it changed my SHA-1 run the command to get the SHA-1 and compare with the atual in your firebase (mine was different)
-> keytool -exportcert -list -v -alias androiddebugkey -keystore %USERPROFILE%.android\debug.keystore
go inside your firebase console (console.firebase.google.com) include the new SHA-1 and download your new google-service.json, change the file in your project and try again - for me works fine
The IOS application works fine due to the firebase didnt need the sha-1, but only the package ID
I Checked again and found that I created a new key for my project, this changed the SHA-1, so I included the SHA-1 in firebase, both for debug and release, after this, google login returned to work
keytool -list -v -keystore C:\Users\biel7\.android\Release.jks -alias Release
using the command above, returns my release SHA-1, because in my case when i tried to create the release APK the google login stopped works

How do i generate a signed APK that uses Firebase Auth?

I've built the App on android studio. When I connect my phone to my PC and build it directly through Android Studio it works. I get the phone verification code and am able to sign in. But when I generate a signed APK to distribute it to others, it always says "Verification Failed" and doesn't let me sign in.
I'm pretty sure there's no problem with the code, because it works perfectly when I build it through Android Studio directly onto my phone.
What Ive Tried:-
I followed the steps in this link and changed the SHA-1 code in my firebase console to the one provided in my Google Console, it still says verification failed.
I also tried to keep only one SHA-1 key in my firebase console which is the one i found in my android project, updated the google-services.json file and tried generating a signed APK, its still says verification failed.
Generate a new SHA1 fingerprint from the console in Android Studio using
keytool -list -v -keystore <absolute path of Keys generated during signed APK generation> -alias <app alias name>
Paste the generated fingerprint in the firebase console and delete the older one.
Hope this works!

Android [App Validation Failed] phone authentication error on Firebase

I have attached firebase on my existing android project and ran it. Here is the scenario:
If the app ran from android studio via developer mode, it(Firebase sign in via phone number) runs smoothly and I manage to log in.
However, whenever I build signed debug apk, Firebase does not allow to sign in. It gives the following message:
This app is not authorized to use Firebase authentication. Please
verify the correct package name and SHA-1 are configured in the
firebase console (App Validation Failed).
I have SHA-1 and SHA-256 key installed on Firebase console generated from my windows machine.
I would have normally provided the code however, I am guessing there is nothing wrong with the code. It works fine with the debug process. I have changed to the up-to-date google-services file from console.
Any help would be highly appreciated. Thanks in advance.
Here is my error:
When debugging, I used the normal debug key from .android/debug.keystore and this key is stored in the Firebase SHA1 field.So it worked perfectly. While trying to create a signed version, I generated a separate keystore file and created signed apk using that. Now, since the SHA1 key varied from the debug, the app was not recognized on the firebase console.
I changed the signed key to debug key. I did not want to go through a lot of changes.
If you are using another key to sign your production apk, you can obtain SHA-1 fingerprint like this:
keytool -exportcert -list -v \
-alias <your-key-name> -keystore <path-to-production-keystore>
Then you will obtain something like this:
Certificate fingerprint: SHA1: DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09
After that just copy SHA1 fingerprint and paste in your firebase's project adding new digital print in following menu:
Project Overview => Pulse in the cog (settings) => Project Configuration => scroll to bottom => add digital fingerprint.

Google Sign In not working when built in my Android Studio

A third-party has developed the main structure for my app, including a Google Sign In. When they test it, it works. When I run the APK that they built, it works. When I build using the project files, it fails with a handleSignInResult:false error.
I've reinstalled Android Studio, installed all the possible SDKs, but to no avail. Does anybody have any idea why one project will build successfully on one computer, but not on mine?
Could it be something to do with the SHA-1?
Yes...You guessed it right.Its about SHA-1 Key.
You need to add you SHA-1 key generated from your PC keystore
How to get SHA-1 from Android Studio ?
Than add that key in your Firebase console or in Google Console
How to add SHA-1 key to console ?
First thing we need SHA-1 key for integrate google sign in we need to register this key in google developer or google api console,
As per my or other experiance SHA-1 key will change when you change your systm so you need to replace your SHA-1 key with latest from your systme.
You need to Generate Your SHA-1 Release Key for Gmail Login After Build Apk
Follow step
1.Open CMD terminal
Goto Java folder using
1. cd java
2. cd jdk1.8.0_112
3. cd bin
C:\Program Files\Java\jdk1.8.0_112\bin>
Enter Following Command:
keytool -list -v -keystore "PATH OF .jks Keystore" -alias android
Note: android is my Keystore Alias
then you will get this : Enter keystore password(Enter your keystore password)
Just update your sha-1 to firebase and goo to tools->Firebase->Authentication->click Connect to firebase.It worked for me;)
Get your sha from Gradle->app->task->android->click Signing report
copy the sha1 past to firebase project settings bottom.

Android Firebase Dynamic Links setup - SHA-1 not recognized

i am trying to setup my android app to use firebase dynamic links and am experiencing a problem in setting it up in the firebase console.
i had previously added my app to my firebase project to use the realtime database and it works with no isssues. i included the app's debug SHA-1 (which i obtained from the app-debug.apk).
now in the firebase dynamic links console screen, i can select my app from the drop-down list but it shows a warning in red "Please add SHA-1 for this Android app".
i even deleted the app from my firebase project and then added it again, also including the SHA-1 but i still get the red warning in the dynamic links console page when i select the app.
i'd appreciate any help in sorting this problem out (so that it recognizes the SHA-1).
note: i have 2 other apps which are included in my firebase project. one has a SHA-1 include and the other not. if i select these apps in the dynamic links console screen, the one with the SHA-1 selects with no warning message and the one without a SHA-1 displays (as expected) the warning message.
thanks
You need to add the SHA1 and SHA256 from your production certificate to firebase console
Log into firebase console
Select your firebase project, click on Configuration
Find your Android App, then go to SHA certificate fingerprints and add both the SHA1 and SHA256 fingerprints for your production certificate.
To obtain the SHA1 and SHA256:
keytool -list -v -keystore your_release_certificate.jks
You should also add your debug SHA1 certificate, go to your project folder and execute
./gradlew signingReport
your debug SHA1 (and all of them) will look like this:
8B:5F:27:7C:A6:59:9A:7C:BB:EF:2F:8B:17:A2:F6:1D:31:3B:73:E6
well, after doing NOTHING but trying again about 12 hours later, it's accepting the SHA-1. so i seems like firebase needs some time to process adding the SHA-1. IT WOULD BE NICE IF THEY INDICATED THAT WITH THEIR RED WARNING OF "Please add SHA-1 for this Android app". so annoying!
Go to the folder where you install your Android Studio nd then jre->bin, for me its like that:
"C:\Program Files\Android\Android Studio\jre\bin"
Then open cmd/terminal their and type the following command
./keytool -list -v -keystore
"C:\Users\USERNAME\.android\debug.keystore" -alias androiddebugkey
-storepass android -keypass android

Categories

Resources