Using session/cookie with API calls


#1

I’ve been added facebook OAuth using WebBrowser.openAuthSessionAsync.
In backend, I’m using nodeJS+passport-facebook and I have following route to test, if user is logged in:

  app.get("/checkIfLoggedIn", (req, res) => {
    if (req.user) {
      res.send({ isLoggedIn: true });
    } else {
      res.send({ isLoggedIn: false });
    }
  });

If I navigate above route with WebBrowser.openAuthSessionAsync, everything seems to be ok, and I get isLoggedIn: true

Is there way to get cookies somehow so I can make API calls with axios/fetch?


#2

hello! if you want to use the session inside of your app then you should create the login screen in the app rather than using WebBrowser.openAuthSessionAsync. that said, i’d recommend implementing an auth flow that returns a token rather than depending on session for your app

you can read more about cookies vs tokens here: https://auth0.com/blog/cookies-vs-tokens-definitive-guide/