Hi, I’ve been having a blast working through Photon examples and tutorials. So much fun that I want to put a few of the web interfaces on a public web page, so that people can see them work.
Two things:
Is there an easy way to keep my deviceIDs and access tokens private? I don’t want them to be available to anyone who clicks View Source.
Many of the examples automatically generate a “results” page. Can I supress that online, or capture it a different way? The people who will see these examples will be able to see the servo action, or the diode flashing, so i don’t need to display a results page.
I wrote up an example of using Particle API JS and prompting for username and password in a web form and optionally storing only a temporary access token only in a browser cookie. It uses jquery so it might be a little more than you’re looking for, but it might have some tricks that you might find helpful. It runs entirely in the browser, no server code required.
on that last example, won’t the javascript – with the device ID and the access code – be visible? Or am I reflecting egregious ignorance of how this could work on a publicly accessible Web page?
The example as-is will show the credentials, correct. If you combine this with a server back-end (PHP, or nodeJS, or…) you should be able to circumvent this. You then make calls using the javascript to the server, which will relay them to the cloud, handling the credentials in the server. Guess that’s what they call a proxy(?)