我想在我的cordova应用程序中使用google plus身份验证 .
1. Generate keystore
keytool -genkey -v -keystore <keystoreName>.keystore -alias <Keystore AliasName> -keyalg <Key algorithm> -keysize <Key size> -validity <Key Validity in Days>
2. Create android release version
cordova build android --release
3. Sign My Apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore <keystoreName>.keystore android-release-unsigned.apk <alias>
4. Optimize my APK
zipalign -v 4 android-release-unsigned.apk <output name>.apk
5. ADD android app in: http://console.firebase.google.com.
6. Get hash from my keystore
keytool -exportcert -keystore <keystoreName>.keystore -list -v -alias <alias>
7. Add SHA1 hash for my adroid app
8. After that i can see client id for android in: https://console.developers.google.com/apis/credentials?project=
9. I'm install this plugin: https://github.com/EddyVerbruggen/cordova-plugin-googleplus.
10. My code in 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
}
);
I'm install apk on my android device and always get error 10.
我安装并成功使用了cordova的facebook插件 . 这很好用!但我无法用谷歌解决问题 . 我究竟做错了什么?
有谁能够帮我...
我重新生成了密钥库...重新安装cordova ...重新安装googlepus插件...
1 回答
My problem solved!!!
我使用clientID "Web client (auto created by Google Service)" 而不是clientID "Android client for com.android.app (auto created by Google Service)" . 这是工作!我得到令牌和用户数据!