I want to use google plus authentication in my cordova app.
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.
I installed and successfully use facebook plugin for cordova. It’s work good! But i can’t solve problem with google. What am I doing wrong?
Can anybody help me…
I regenerated keystore… Reinstall cordova… Reinstall googlepus plugin…
2
Answers
My problem solved!!!
I use clientID "Web client (auto created by Google Service)" instead of clientID "Android client for com.android.app (auto created by Google Service)". It's work! I get token and user data!
In my case, I was getting this error because I was trying to log-in from within the Emulator. This fails because the the emulator installs the
app-debug.apk
which does not have proper SHA1 fingerprints, unlike the signedapk
oraab
( bundle ).I installed the signed version I generated from Android Studio and installed that to a actual device which made it work.