简体   繁体   中英

NativeScript Firebase Google Authentication

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:

  1. Used keytool to get the SHA1 and added it to the Firebase console.
  2. Downloaded the google-services.json file and added it to the app/App_Resources/Android folder.
  3. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM