Google plus authentication on Ionic

Asked

Viewed 82 times

0

I’m trying to create a login with google plus in Ionic 4 on android platform, but is always coming back an error [10], which according to the google documentation, is a configuration error, but I did not find where I am missing.

What I’ve done so far:

  1. I created the project on firebase and added an android project.
  2. I enabled Google Authentication on firebase console
  3. I added a SHA-1 fingerprint to the firebase console, created by the terminal (linux).

login code on Ionic

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);
  });

}

Every time I try to log in, it returns a '10' error, but I haven’t figured out what’s missing yet.

1 answer

0

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 are working on the office PC and your home PC, make sure to generate the SHA-1 fingerprint on each machine and add it to the project settings on Firebase Android.

If you added a single SHA-1 fingerprint and tried to use Google + auth from another machine, the authentication will fail and you will get the famous Erro 10.

To generate a SHA-1 Debug fingerprint key.

On 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 be 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: google developers.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.