且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拒绝显示框架,因为它在 android webview 中将 X-Frame-Options 设置为“DENY"

更新时间:2021-09-09 21:57:43

您需要将日历设为公开.这就是正在发生的事情——由于您尝试显示的日历未公开共享,因此 Google 日历首先想知道您是谁,以便决定向您展示什么,因此它会将您发送到 Google 登录页面.登录页面通过禁止在 iframe 中显示自己来保护自己免受点击劫持(这就是 'X-Frame-Options' 设置为 'DENY' 的意思).

You need to make your calendar public. This is what is happening -- as the calendar you are trying to display isn't shared publicly, Google Calendar first wants to know who you are in order to decide on what to show to you, so it sends you to the Google login page. The login page protects itself from click hijacking by disallowing displaying itself in an iframe (that's what 'X-Frame-Options' is set to 'DENY' means).

如果您将日历设为公开可见,日历只会显示它,而不会先尝试让您登录.关于如何共享日历,请参阅:https://support.google.com/calendar/answer/37083

If you make the calendar publicly visible, Calendar will just show it, without trying to log you in first. On how to share the calendar, see this: https://support.google.com/calendar/answer/37083

您可以通过创建一个将日历嵌入 iframe 的简单测试页面,然后在未登录 Google 服务的 Google Chrome 隐身窗口中打开它,在桌面上简单地测试这是否适用于 WebView.在您公开共享日历之前,Chrome 也将拒绝显示日历.

You can trivially test on desktop whether this will work in WebView by creating a simple test page that embeds the calendar in an iframe, and then opening it in an Incognito window of Google Chrome, where you are not logged into Google services. Chrome will also be refusing to show Calendar until you make it publicly shared.