0

I am trying google signin using AngularFire2. Google authentication is working perfectly when I use this.afAuth.auth.signInWithPopup. But signInWithPopup is only for browser and wont work for mobile app. As per google documentation, signInWithRedirect should be used for app. I tried using method but it is opening browser for signin.

Instead I tried using cordova google plus plugin to signin, and using the accessToken to authenticate Firebase.

When I try to call login method of cordova plugin, it is throwing error, and error has only '17' number.

I have following questions

  • Is there anything I am missing?
  • What is the better way to sign in ionic mobile app using google plus?
  • what is the meaning of error '17'?

Here is my code

this.gPlus.login({
    webClientId: '<myClientID>',
    offline: true
  })
  .then(res => {
    this.afAuth.auth.signInWithCredential(res.accessToken);
  }, (err) => {

    console.log(err) // Logging 17 here.
  })
  .catch(err => {
    console.log(err);
  })
Laxmikant Dange
  • 7,606
  • 6
  • 40
  • 65

1 Answers1

0
let provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithRedirect(provider).then(() => {
    firebase.auth().getRedirectResult().then((result)=>{

    }).catch(function(error){

    }) 
})

Use this code for signin using google. It will surely open browser for signin but it can also have facility for getting you back to the desired page in application. You will get the data as well.

AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57