-2

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?

Yurash
  • 51
  • 3
  • it is not very clear what you are doing and when the problem occurs. Maybe sharing some code would help. – Jacobvdb Apr 15 '13 at 18:04

1 Answers1

1

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).

Brian
  • 433
  • 1
  • 7
  • 16
  • Yes, I understand about redirections and I did allow execution to anonymous users. When I making first url get with link like "https://script.google.com/macros..." I get 302 error and in the response there is text like "Location":"https://script.googleusercontent.com/macros/echo?user_content_key=..." so I tried to use that new location in second url get - but I got same error and in the response text location was with first url. So I'm oscillating between this two urls – Yurash Apr 16 '13 at 04:02
  • 1
    please post some code samples (client and app script)... I have used ContentScript for REST JSON backend and have not have this issue (only have the one 302 and then get the file). – Brian Apr 16 '13 at 22:38