【发布时间】:2014-04-16 03:31:28
【问题描述】:
我有一个使用 Google Drive API 的 JavaScript 应用。我在这里阅读了如何打开标准共享对话框:https://developers.google.com/drive/web/manage-sharing
<head>
...
<script type="text/javascript" src="https://apis.google.com/js/api.js"></script>
<script type="text/javascript">
init = function() {
s = new gapi.drive.share.ShareClient('<MY_APP_ID>');
s.setItemIds(["<MY_FILE_ID>"]);
}
window.onload = function() {
gapi.load('drive-share', init);
}
</script>
</head>
<body>
<button onclick="s.showSettingsDialog()">Share</button>
</body>
似乎我做的一切都是正确的,当我点击我的share 按钮时,对话框开始加载但无法加载。
在我看到的控制台中:
Refused to display 'https://drive.google.com/share?...' in a frame
because it set 'X-Frame-Options' to 'SAMEORIGIN'.
我用谷歌搜索了这个错误,我发现在 SO 和其他网站中有一些类似的问题,但它们没有帮助。我猜谷歌不允许自己出现在非谷歌网站的框架中(因为“SAMEORIGIN”)。
如何在我的应用中打开共享对话框?
【问题讨论】:
-
如果您包含用于尝试打开标准共享对话框的代码,将会有所帮助。
-
@Fresh,包含代码
标签: javascript google-drive-api same-origin-policy x-frame-options