node.js - Node/Express API - decouple oAuth login from server -
i have developed rest api using node.js , express , client application using angular.
i authenticate users using third party oauth services (twitter initially), of tutorials/reading have done suggests must have webapp coupled server avoid security exceptions due different domains.
i wish keep server , client decoupled plan build native apps @ point in future.
can advise on workflow required such setup? surprised if server , app must coupled given native apps have decoupled setup.
looking advice, thoughts, links ;)
for getting access token in order fetch information of user advised make request server (you can securely store clientid , secret there).
- you have endpoint can authorize client specific service, let's
/oauth/twitter/authenticate
. call endpoint clickinglogin twitter
button of angular application - you have endpoint twitter going return information, in success or failure, e.g.
/oauth/twitter/callback
. store information in success , potentialy establish user session. perhaps have endpoint checking if user has active user session.
there node module make life easier , incredibly easy use express middleware, passport , has twitter authentication strategy.
Comments
Post a Comment