I currently have a simple backbone.js application served from my domain (example.com), which is provided an Oauth token. Specifically, I pass the Oauth token through my page template into the constructor arguments of my javascript class (Backbone model). The backbone.js application (running in browser) then uses the Oauth token to talk directly to a remote server (not the same server from which the page was served).
Is it safe to provide the javascript code the Oauth token like this?
The entire page is served via https, so there is effectively no concern about MITM attacks. The browser also has a cookie with the users sessionid in it, so I don't think that's much different than providing the browser javascript with the Oauth token.
If this is terrible, are there any alternative methods that could be employed? Would storing the Oauth token in a cookie be any better? (same security implications as having a sessionid stored in a cookie).