Refused to display a frame because it set X-Frame-Options to 'DENY in android webview

后端 未结 2 1114
忘掉有多难
忘掉有多难 2020-12-16 23:07

When I try to show the google calendar in webview , it show some error:

[INFO:CONSOLE(0)] \"Refused to display \'https://accounts.google.com/ServiceLogin?ser         


        
相关标签:
2条回答
  • 2020-12-16 23:15

    If your calender is not public make sure you are loged in and third party cookies are accepted. Otherwise google will forward you to the login page what will cause an error because within an iframe google will deny access.

    0 讨论(0)
  • 2020-12-16 23:30

    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).

    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

    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.

    0 讨论(0)
提交回复
热议问题