【问题标题】:python proxy to embed a google apps script service in an iframepython代理在iframe中嵌入谷歌应用脚​​本服务
【发布时间】:2012-05-09 05:41:22
【问题描述】:

“X-Frame-Options: SAMEORIGIN”标头阻止 Apps 脚本在不是来自 sites.google.com(或 docs.google.com)的页面中呈现

如何创建 python 代理以从 IFrame 工作。我怀疑代理需要替换 SAMEORIGIN 标记并使用 ajax 样式的 POST 命令。 这对我来说是一个新领域,以前不需要设置代理。

Google Apps 脚本页面示例: https://docs.google.com/macros/exec?service=AKfycbyrbgVS39Hf-RHYVPbnCKzf_uVaD0sGeFSKEqyRIw

这个代理解决方案看起来很接近: How do I get my simple twisted proxy to work?

我找到了在 App Engine 上设置代理的说明,但是使用 ajax 样式的 POST 命令失败了: http://www.labnol.org/internet/setup-proxy-server/12890/

这是一个已知的 Google Apps 脚本问题 #546 和 #522。大约 1 岁,大约有 100 人在寻找解决方案。

【问题讨论】:

    标签: python twisted reverse-proxy google-apps-script


    【解决方案1】:

    bs2grproxy 进行了一些小的改动。 我在这里发布了解决方案: http://code.google.com/p/google-apps-script-issues/issues/detail?id=546#c104

    变化:

    在文件 bs2grproxy.py 的第 48 行下方,“raise Exception('Unsupported ...” insert:

            scm = 'https'
    

    在第 134 行下方,“raise Exception('Requested ...”插入:

                if fetched:
                    if resp.headers.get('Content-Type', '').find('html') >= 0:
                        resp.content = resp.content + '<style type="text/css"> .warning-panel {display: none;} </style>'
                        resp.headers['x-frame-options'] = 'IGNORE'
                        logging.info("warning-panel hidden and x-frame-options reset")
    

    您可能还需要在 bs2grproxy.py 中更改代理超时,如下所示:

    resp = urlfetch.fetch(new_path, self.request.body, method, newHeaders, False, False, 30)
    

    艾迪。

    【讨论】:

      猜你喜欢
      • 2012-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-29
      • 2012-10-31
      • 2017-11-18
      • 1970-01-01
      • 2013-04-21
      相关资源
      最近更新 更多