# Ionic 2 Facebook Auth with InAppBrowser

**URL:** <https://forum.ionicframework.com/t/ionic-2-facebook-auth-with-inappbrowser/83431>\
**Category:** ionic-v3\
**Created:** [March 19, 2017, 6:50pm UTC](https://forum.ionicframework.com/t/ionic-2-facebook-auth-with-inappbrowser/83431 "2017-03-19T18:50:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fuatkestane](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@fuatkestane](https://forum.ionicframework.com/u/fuatkestane)\
**Post date:** [March 19, 2017, 6:50pm UTC](https://forum.ionicframework.com/t/ionic-2-facebook-auth-with-inappbrowser/83431/1 "2017-03-19T18:50:24Z")

</div>

Hi everybody,

I am developing mobile application. I should use facebook login in my app and there is facebook auth service in my app. When listened the [socket.io](http://socket.io), it must close browser. I think session opens InAppBrowser. I want the browser to close and login when the session is opened.

Thanks a lot 🙂

This my code is here:

```
authFacebook() {
    this.platform.ready().then(() => {
      this.browser = new InAppBrowser(Global.address + "/auth/facebook", "_blank", "location=no");
    });
    Global.socket.on("auth", (res) => {
      console.log("AUTH:", JSON.stringify(res));
      if (res.ok) {
        Global.user = res.data;
        Global.socket.emit("new_user", this.email);
        this.getPages();
      }
      else {
        console.log("ERROR:", res.error);
      }

      this.platform.ready().then(() => {
        this.browser.close();
      });
    });
    this.navCtrl.push(TabsPage);
  }
```

---

<div class="post-metadata">

**Author:** ![PWHSoftware](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/pwhsoftware/32/107905_2.png) [@PWHSoftware](https://forum.ionicframework.com/u/PWHSoftware)\
**Post date:** [April 1, 2017, 5:31am UTC](https://forum.ionicframework.com/t/ionic-2-facebook-auth-with-inappbrowser/83431/2 "2017-04-01T05:31:55Z")

</div>

Have you tried using the Native authentication instead of InAppBrowser?

Facebook Authentication with Ionic 2/Ionic Cloud
