【发布时间】:2018-04-04 06:21:04
【问题描述】:
我想在我的 cordova 应用中使用 google plus 身份验证。
1.生成密钥库
keytool -genkey -v -keystore <keystoreName>.keystore -alias <Keystore AliasName> -keyalg <Key algorithm> -keysize <Key size> -validity <Key Validity in Days>
2。创建安卓发布版本
cordova build android --release
3.签署我的 Apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore <keystoreName>.keystore android-release-unsigned.apk <alias>
4.优化我的 APK
zipalign -v 4 android-release-unsigned.apk <output name>.apk
5.将安卓应用添加到:http://console.firebase.google.com。
6.从我的密钥库中获取哈希
keytool -exportcert -keystore <keystoreName>.keystore -list -v -alias <alias>
7.为我的安卓应用添加 SHA1 哈希
8.之后我可以看到 android 的客户端 ID:https://console.developers.google.com/apis/credentials?project=
9.我正在安装这个插件:https://github.com/EddyVerbruggen/cordova-plugin-googleplus。
10.我在应用程序中的代码:
window.plugins.googleplus.getSigningCertificateFingerprint(
function (fingerprint) {
alert(fingerprint); // SHA1 HASH - It's same like in console.firebase.google.com
}
);
window.plugins.googleplus.login(
{
'scopes': '',
'webClientId': '62......39.6-..................jjka5b...v87q7.apps.googleusercontent.com', // optional clientId of your Web application from Credentials settings of your project - On Android, this MUST be included to get an idToken. On iOS, it is not required.
'offline': true,
},
function (obj) {
alert(JSON.stringify(obj));
},
function (msg) {
alert('error: ' + msg); // error 10
}
);
我在我的 android 设备上安装 apk,但总是收到错误 10。
我为cordova 安装并成功使用了facebook 插件。它的工作很好!但我无法用谷歌解决问题。我做错了什么?
谁能帮帮我……
我重新生成了密钥库...重新安装cordova...重新安装googlepus插件...
【问题讨论】:
-
我也遇到了同样的问题,使用 Cordova CLI 卸载所有插件并重新安装。
-
我重新安装了...并尝试其他版本5.1.1、5.1.2...没有效果...
-
Google 控制台中的设置可能有问题...谁能帮帮我...
-
您在安装插件时提供了 REVERSED_CLIENT_ID?
-
是的,我添加了它。它只需要IOS。我尝试在另一个版本的cordova中创建空项目,添加了google-plus-plugin ...我再次收到错误10 ...可能是我在google控制台中的设置有问题...我不知道...
标签: android cordova plugins certificate google-plus