I've asked this question on stackoverflow, but i think this is a more appropriate place for it.I'm creating an app for iOS, Android and the Web. I created a separate Restful Data Service that is meant to be consumed by all three environments, so I separated the Logic, and all of the apps can consume it at api.mysite.com. To login, you have to hit the DataService, pass the username and password, and it returns a token, for which should be used in each subsequent request to the DataService. Thats all fine and dandy for iOS and Android, but gets a little tricky when it comes to JavaScript/HTML/PHP environment.In that environment, PHP hits the server for a few initial objects that it bootstraps the rendered HTML page with. Then, the javascript runs client side and consumes the bootstrapped data. If the JavaScript needs to edit, get more, or delete objects, it has to hit the DataServer.How should I construct the communication between the WebServer, the DataServer and that Javascript? I assume I'd need to sessions between the WebServer and the Javascript, and Tokens between the WebServer and the DataServer...And I'd need to either bootstrap the Token to the rendered HTML so the Javascript can communicate with the server as well, or have it communicate with proxy scripts on the WebServer, which then communicates to the DataServer as necessary. Whats the best practice here? Is there one? Whats a good structure to follow?
Login Tokens Remote DataServer for use in a Javascript/HTML-PHP environment
php;javascript;web api;web servers