GAE code proxy

2015年1月19日 星期一

GAE code proxy

解決 用 iFrame 內嵌 google app script 時,refuse display的問題

Refused to display '' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

在 GAE 上架設code proxy, 透過 GAE  server 去 access Google Script

1. 安裝 physon 2.7.8 (不要用2.7.9)

2. 安裝 Google App Engine SDK for Python

 I used this proxy
  and made a few minor changes to it.

1) Use GAE. To setup a GAE account and learn how to upload, see:

2) Download the bs2grproxy code etc from

3) Use the attached file 
  OR ...
In file below line 48, "raise Exception('Unsupported ..." insert: 

            scm = 'https'
4) Use the attached file 
  OR ...
  In file 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'
              "warning-panel hidden and x-frame-options reset")

5) Update the file: app.yaml 
  application: you-app-name 

6) Upload to the server
7) Set the host.
  i.e. on your new proxy goto
 and set the host to:

with luck .. the proxy now works 

Workaround, posted May 16th. Time out issue. 

Change the proxy time out in, 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. 

0 意見 :