Authentication with google plus on Ionic
I am trying to create a login with google plus in ionic 4 on the android platform, but it is always coming back an error [10], which according to google documentation, is a configuration error, but I did not find where I am going wrong.
What I've done so far:
- I created the project in firebase and added an android project.
- enabled Google Authentication on firebase console
- Added a SHA-1 fingerprint on firebase console, created by terminal (linux).
Ionic login code
async doGoogleLogin(){
this.googlePlus.login({
'scopes': '',
'webClientId': 'meuWebClientId.apps.googleusercontent.com',
'offline': true
})
.then(user =>{
this.saveGoogleUser(user);
this.router.navigate(["/home"]);
}, err =>{
this.presentAlert("Error Console", err);
});
}
Whenever I try to log in, it returns an error '10', but I haven't figured out what's missing yet.
1 answers
You need to correctly include the fingerprint certificate SHA-1
.
Keep in mind that each PC generates a different and unique SHA-1 fingerprint. For example: if you're working on your office PC and your home PC, make sure you generate the SHA-1 fingerprint on each machine and add it to your project settings in Firebase Android.
If you added a single SHA-1 fingerprint and tried to use Google + auth from another machine, authentication will fail and you will get the famous Erro 10
.
To generate a debug SHA-1 Fingerprint Key.
No Windows:
keytool -exportcert -list -v -alias androiddebugkey -keystore C:\Users\<user>\.android\debug.keystore
On Mac OSX and Linux:
keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
Default password: android
And the result will look something like this:
***************** WARNING WARNING WARNING *****************
* The integrity of the information stored in your keystore *
* has NOT been verified! In order to verify its integrity, *
* you must provide your keystore password. *
***************** WARNING WARNING WARNING *****************
Alias name: androiddebugkey
Creation date: May xx, xxxx
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: C=US, O=Android, CN=Android Debug
Issuer: C=US, O=Android, CN=Android Debug
Serial number: 1
Valid from: Mon May xx 13:00:59 IST 2017 until: Wed May 15 13:00:59 IST 2047
Certificate fingerprints:
MD5: 26:60:AC:51:D1:18:05:F4:AE:2A:82:00:0A:0C:5E:FE
SHA1: E0:93:D6:BF:DA:16:6D:30:89:3x:F7:03:52:BC:18:12:4E:71:76:A1
SHA256: D0:4E:0A:E8:C9:1C:68:AD:A3:E4:9B:4E:28:7E:FC:26:81:31:D6:30:EC:21:95:C0:CE:C0:70:6F:E9:EB:11:AC
Signature algorithm name: SHA1withRSA
Version: 1
Reference: developers.google