GAE code proxy
解決 用 iFrame 內嵌 google app script 時,refuse display的問題
Solution:
在 GAE 上架設code proxy, 透過 GAE server 去 access Google Script
1. 安裝 physon 2.7.8 (不要用2.7.9)
https://www.python.org/downloads/
2. 安裝 Google App Engine SDK for Python
https://cloud.google.com
Refused to display 'https://script.googleusercontent.com/macros/echo?user_content_.....' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
Solution:
在 GAE 上架設code proxy, 透過 GAE server 去 access Google Script
1. 安裝 physon 2.7.8 (不要用2.7.9)
https://www.python.org/downloads/
2. 安裝 Google App Engine SDK for Python
https://cloud.google.com
I used this proxy https://code.google.com/p/bs2grproxy/ and made a few minor changes to it. 1) Use GAE. To setup a GAE account and learn how to upload, see: http://www.labnol.org/internet/setup-proxy-server/12890/ 2) Download the bs2grproxy code etc from https://code.google.com/p/bs2grproxy/ 3) Use the attached bs2grproxy.py file OR ... In file bs2grproxy.py below line 48, "raise Exception('Unsupported ..." insert: scm = 'https' 4) Use the attached bs2grproxy.py file OR ... In file bs2grproxy.py below line 134, "raise Exception('Requested ..." insert: if fetched: if resp.headers.get('Content-Type', '').find('html') >= 0: resp.content = resp.content + '' resp.headers['x-frame-options'] = 'IGNORE' logging.info("warning-panel hidden and x-frame-options reset") 5) Update the file: app.yaml lines: application: you-app-name script: bs2grproxy.py 6) Upload to the server 7) Set the host. i.e. on your new proxy goto www.mydomain.com/_bs2admin/ and set the host to: docs.google.com with luck .. the proxy now works
Workaround, posted May 16th. Time out issue. Change the proxy time out in bs2grproxy.py, like this: resp = urlfetch.fetch(new_path, self.request.body, method, newHeaders, False, False, 30) Slow GAS code needs a longer time out than the default. But dont go over 1 min, as you hit the GAE time out.
留言
張貼留言