I am using Ionic2/Cordova to log into an app using Google
.
I try the following, based on ionic-native GooglePlus and this demo:
loginGoogleCordova(): void {
GooglePlus.login({
'webClientId': 'mywebclientid.apps.googleusercontent.com',
'offline': true
}).then(googleData => {
if (!firebase.auth().currentUser) {
firebase.auth().signInWithCredential(firebase.auth.GoogleAuthProvider.credential(googleData.idToken))
.then((success: FirebaseAuthState) => {
this.doAlert("signInWithCredential successful " + JSON.stringify(success));
this.signIn(success, AuthProviders.Google);
})
.catch((gplusErr) => {
console.error('GooglePlus failed ' + gplusErr);
this.doAlert("GooglePlus failed " + JSON.stringify(gplusErr))
});
}
}, error => {
this.loading.dismiss();
console.error('loginGoogle: ' + error);
this.doAlert('loginGoogle: ' + error.message);
});
}
Which looks like it makes progress, because it now accesses the Google api. But I get the following:
Invalid parameter for redirect uri: Invalid Scheme:
mywebclientid.apps.googleusercontent.com
But when I check my Web client ID
in the Firebase Authentication
→ Sign-in Method
, this is the Web client ID
.
Also, when I installed the plugin, I ran:
$ ionic plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=mywebclientid.apps.googleusercontent.com
As you can see, it is also in the Xcode’s plist
file:
UPDATE
I did notice that when looking at my Google APIs, that the CLIENT ID
is created for Web client
:
I that the problem? Should I create one CLIENT ID
for iOS
and another for Android
? Then have if statements
:
if iOS
use iOS client id
if Android
use Android Client id
But as you can see from [here][5], it uses: 'webClientId': 'USE-YOURS-HERE!!!!!.apps.googleusercontent.com'
As a result, I am a little confused, and any advise would be appreciated.