我想在我的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。创建Android发行版
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。在以下网址添加Android应用:http://console.firebase.google.com。
6。从我的密钥库中获取哈希
keytool -exportcert -keystore <keystoreName>.keystore -list -v -alias <alias>
7。为我的adroid应用添加SHA1哈希
8。之后,我可以在https://console.developers.google.com/apis/credentials?project=
中看到Android的客户端ID9。我正在安装此插件:https://github.com/EddyVerbruggen/cordova-plugin-googleplus。
10。我在app中的代码:
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插件......
答案 0 :(得分:0)
我的问题解决了!!!
我使用clientID “网络客户端(由Google服务自动创建)”而不是clientID “用于com.android.app的Android客户端(由Google服务自动创建)”。这是工作!我得到令牌和用户数据!