Friday 17 March 2017

Node / Passport back-end working with Android?

I've followed a simple Scotch.io tutorial to build an authentication site set up using Node.js, Express, and Passport. I can now have users register, sign in, and navigate to a profile site that displays some information about the user, but I was wondering how I can get the same application to work for an Android client. I get confused when I look at the code using Passport like

*In a file that defines my routes*
app.post('/login', passport.authenticate('local-login', {
    successRedirect : '/profile',
    failureRedirect : '/login',
    failureFlash : true
}));

I understand how the redirects will work for browser, but I'm not sure how that'll translate when working with an Android client. When the credentials match for a user, what do I respond to the Android client with? Am I using Passport wrong, or should Passport not be used in my case? I've done some research and found that I may need migrate to token generation, which I don't really understand. My questions boil down to

  • Should I be using Passport if I want to serve to web and mobile clients?
  • If I can use Passport, how would one be responding to a mobile request? Will it be completely separate from how it currently responds to web requests?
  • Is it normal to separate endpoints for web and mobile users?
  • If I'm not using Passport, what should I be using instead?


via QuayShawn

No comments:

Post a Comment