简体   繁体   English

NativeScript Firebase Google身份验证

[英]NativeScript Firebase Google Authentication

I am using NativeScript (Vue app) with the Firebase plugin to allow Google account logins. 我正在将NativeScript(Vue应用程序)与Firebase插件一起使用,以允许Google帐户登录。 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." 登录按钮重定向到Google登录页面,但我无法登录。显示的错误是“此帐户已在您的手机上”。

According to the plugin page this will happen if the SHA1 fingerprints have not been uploaded to the Firebase console. 根据插件页面,如果未将SHA1指纹上载到Firebase控制台,则会发生这种情况。

There is no difference between a physical device or the emulator, neither between "tns run" and "tns build" and then uploading the APK manually. 物理设备或仿真器之间没有区别,“ tns run”和“ tns build”之间没有区别,然后手动上传APK。

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. 使用keytool获取SHA1并将其添加到Firebase控制台。
  2. Downloaded the google-services.json file and added it to the app/App_Resources/Android folder. 下载了google-services.json文件,并将其添加到app / App_Resources / Android文件夹中。
  3. Used apksigner to verify the SHA1 and it matches what I have in the Firebase console as well as the keystore. 使用了apksigner来验证SHA1,它是否与Firebase控制台以及密钥库中的内容匹配。

When I check the Firebase Analytics page I can see the connection, so I am using the correct app URI etc. 当我查看Firebase Analytics页面时,可以看到连接,因此我使用的是正确的应用URI等。

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. 我在SO上注意到了与此有关的另一个问题,但这个问题尚未得到回答,而且已有几年历史了。

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 . 对我tns build android --bundle从项目文件中删除“平台”目录,然后运行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. 我还要验证您可以使用的SHA1指纹: keytool -exportcert -list -v \\ -alias androiddebugkey -keystore ~/.android/debug.keystore与Firebase设置中列出的指纹相同。 ( https://developers.google.com/android/guides/client-auth ) 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. 要检查的另一件事是在添加SHA1指纹后下载了google-services.json文件。 But it seems like you've already done most of that. 但是似乎您已经完成了大多数操作。

  • You have to provide yet another SHA-1 fingerprint. 您必须提供另一个SHA-1指纹。
  • Locate your debug.keystore (usually in %USERPROFILE%.android\\debug.keystore). 找到您的debug.keystore(通常在%USERPROFILE%.android \\ debug.keystore中)。
  • Use keytool to retrieve key information as you did with your upload keystore. 与上载密钥库一样,使用keytool检索密钥信息。
  • Put retrieved SHA-1 into firebase authentication console. 将检索到的SHA-1放入Firebase身份验证控制台。

That's all folks. 那是所有人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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