Ionic Auth social login browser [PWA]


#1

Hi Guys,

I want to build a PWA with Ionic and to make use of Ionic auth. Ionic auth already supports social login providers, but I don’t have a clue about how to make this ionic auth login flow work with social providers within my browser.

My question is: does anyone have any experience with this and how to do this?

I really would like to use the ionic auth service within the browser, but I don’t see a way to do this properly yet.


#2

Same problem here, let me share what I tried to do:

    signIn(provider){
      let payload = {'app_id': MYAPPID, 'callback': window.location.href, 'data': ''};
      let login_url = "https://api.ionic.io" + "/auth/login/" + provider;
      this.http.post(login_url, payload).subscribe(
        (data)=>{
          let resp = data.json();
          if( !!resp.data && !!resp.data.url ) window.location.href = resp.data.url;
          }, (err)=>{
            console.error( err );
          })
    }

now calling signIn('facebook') or signIn('google') redirects you to the correct login page at facebook or google, also you are redirected back to a callback URL with the token you need, however the redirect host is http://auth.ionic.io/login?.. which cannot be resolved.

Looks like this domain is to be used for in the in app browser auth flow, in that case the code client code can just parse the token from resulting URL and work from there, however in a PWA I a need to be redirected to the real callback I passed in in the first call to the api.ionic.io.

Is there some secret parameter we can pass in the data part of the payload to make sure the callback url is not changed to auth.ionic.io ?


#3

I have a similar problem.
There is a guide here which is the official angularefire2 library for Firebase.
The problem is when i tried to run it on the emulator or on a real device keeps complaining that firebase is not defined. As i searched it i found that the problem is when you try to get the credentials in this line:
const facebookCredential = firebase.auth.FacebookAuthProvider.credential(res.authResponse.accessToken);

If there is someone who has tried it and made it work could help up resolve it.

Thank you all.


#4

I think that what you’re describing is something entirely different, though it would be nice if it was solved ;-). Did you guys have any experience with the social login pwa issue @mhartington ?


#5

Hello mate, it’s been a while since you’ve posted this and I have a similar problem. There seems to be no articles that cover this post. Did you get anywhere with this? Any help would be much appreciated.