我有一个使用 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”)。
如何在我的应用程序中打开共享对话框?