Is it possible to use google-apps-script as backend for ms on{X}?

486 views Asked by At

I'm trying to use google-apps-script as "prototype-quality" backend with microsoft on{X} ("on{X} (pronounced like 'on-ex') lets you control and extend the capabilities of your Android phone using a JavaScript API to remotely program it") it can do ajax GET/POST, but when I in my onX script trying to query my app script (app script is kinda like this https://github.com/entaq/GoogleAppsScript/blob/master/Android/InventoryContentService.gs) I have error "HTTP/1.1 302 Moved Temporarily" and in the response header there is some new url in "location" parameter. I had tried to use this new url in second request, but again have this "Moved Temporarily" error. Maybe there are settings in header of ajax request that could allow me to overcome redirections?

1

There are 1 answers

2
Brian On

When you are using ContentService in an Apps Script to return Text (JSON, XML, etc), For security reasons, Google Apps Script will actually return a 302 Redirect to a different Domain (GoogelUserContent.com), if you catch this Location header and "GET" that URL, you should be able to see the TEXT. However if you are getting more Redirects after that point, I would check your permissions (I have a feeling you are getting re-directed to the Google Login Screen). If that is the case, you would need to adjus your permissions to accept request from Anonymous (you can implement your own security on the script by passing back your own cookie or hash, etc).