androidiosionic2google-plusionic3

Google plus Native plugin with webClientId


I'm using native Google Plus plugin with Ionic 3 app.

Login() method is like this:

login(){

        GooglePlus.login({
          'webClientId': '*************************'
        }).then((res) => {
            console.log(res);
        }, (err) => {
            console.log(err);
        });

    }

The problem here is about the webClientId.Hence I have created 2 apps on developer console (iOS and Android), it shows 2 different webClientIds.So which value should I give to above code?


Solution

  • Helpful link: Ionic Google Authentication

    Plugin link: enter link description here

    You don't need to put webClientId in GooglePlus.login().

    Your login method should be (if no additional options)-

    GooglePlus.login({}).then((res) => {
        console.log(res);
    }, (err) => {
        console.log(err);
    });
    

    iOS

    You need to put REVERSED_CLIENT_ID in config.xml for iOS.

    <plugin name="cordova-plugin-googleplus" spec="~5.1.1">
            <variable name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps.967272422526-vu37jlptokv45glo2kciu9o2rddm7gte" />
    </plugin>
    

    To find you REVERSED_CLIENT_ID, in developer console go to credentials and click on created iOS credential and Download Plist.

    enter image description here

    Android

    For android you don't need any id, it works on Signing-certificate fingerprint, make sure the Signing-certificate fingerprint and Package name are correct while creating oauth client id.

    enter image description here

    If you are not signing your apk with any created keystore file then take SHA-1 signing-certificate fingerprint of default debug.keystore file.

    keytool -exportcert -keystore C:\Users\Username\.android\debug.keystore -list -v
    

    I have used most common path of debug.keystore (windows). It might be different for you, just look for .android dir.