Issue with Google Authentication in Ionic using @awesome-cordova-plugins/google-plus

Discussão em 'Angular' iniciado por Patrick, Setembro 23, 2024.

  1. Patrick

    Patrick Guest

    I'm using the @awesome-cordova-plugins/google-plus/ngx library to implement Google authentication in my Ionic project. Here’s the code I'm using:

    loginGoogle() {
    const clientId = this.platform.is('android') ? this.androidClientId : this.iosClientId;

    this.googlePlus.login({
    webClientId: clientId,
    offline: false,
    })
    .then((res) => {
    console.log("GOOGLESIGN Login successful", res);
    this.socialLogin(res.userId, 'google', res.email, res.givenName, res.familyName);
    })
    .catch((err) => {
    const errorCode = err?.code ?? 'undefined';
    const errorMessage = err?.message ?? 'undefined';

    this.alert.errorAlert("Error code: " + err);

    if (errorCode === 12501) {
    console.error("GOOGLESIGN Error: User canceled the login.");
    } else if (errorCode === 10) {
    console.error("GOOGLESIGN Error: Incorrect OAuth client configuration.");
    } else {
    console.error("GOOGLESIGN Unknown error during Google login.");
    }
    });
    }


    I'm always receiving errorCode = 10. I have verified that the credentials are correctly set up in Google Cloud with the corresponding SHA-1 for the Android app.

    Has anyone encountered a similar issue or can help me resolve this? Thank you!

    Continue reading...

Compartilhe esta Página