我正在开发一个网站,应该是响应,以便人们可以从他们的手机访问它。该网站有一些安全的部分,可以登录使用谷歌,Facebook,…等(OAuth)。

服务器后端是用ASP开发的。Net Web API 2,前端主要是AngularJS加上一些Razor。

对于身份验证部分,在包括Android在内的所有浏览器中,一切都很好,但谷歌身份验证在iPhone上不起作用,它给我这个错误消息

Refused to display 'https://accounts.google.com/o/openid2/auth
?openid.ns=http://specs.openid.ne…tp://axschema.org/namePerson
/last&openid.ax.required=email,name,first,last'
in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

现在就我而言,我没有在我的HTML文件中使用任何iframe。

我搜索了一下,但没有答案让我解决这个问题。


当前回答

在本例中,他们将报头设置为SAMEORIGIN,这意味着他们不允许在域外的iframe中加载资源。所以这个iframe不能跨域显示

为此,您需要匹配apache或您正在使用的任何其他服务中的位置

如果你使用apache,那么在httpd.conf文件中。

  <LocationMatch "/your_relative_path">
      ProxyPass absolute_path_of_your_application/your_relative_path
      ProxyPassReverse absolute_path_of_your_application/your_relative_path
   </LocationMatch>

其他回答

好吧,在这篇SO文章的帮助下花了更多的时间之后

克服“x帧选项禁止显示”

我设法解决了这个问题,在发布到谷歌url之前,将&output=embed添加到url的末尾:

var url = data.url + "&output=embed";
window.location.replace(url);

有一个解决方案对我来说很有效,参考父母。在获得将重定向到谷歌身份验证页面的url后,您可以尝试以下代码:

var loc = redirect_location;      
window.parent.location.replace(loc);

我测试了所有的项目,但这段代码帮助我:

       ?rs:embed=true

例如,我想在我的应用程序中加载一个pbix。我使用这个代码:

   <iframe id="pageIFrame" class="iFrame" src="http://MyServer/ReportS/powerbi/Test?rs:embed=true"></iframe>

这很有效。

我在Angular 9中也遇到了同样的问题。以下是我做的两步:

Change your YouTube URL from https://youtube.com/your_code to https://youtube.com/embed/your_code. And then pass the URL through DomSanitizer of Angular. import { Component, OnInit } from "@angular/core"; import { DomSanitizer } from '@angular/platform-browser'; @Component({ selector: "app-help", templateUrl: "./help.component.html", styleUrls: ["./help.component.scss"], }) export class HelpComponent implements OnInit { youtubeVideoLink: any = 'https://youtube.com/embed/your_code' constructor(public sanitizer: DomSanitizer) { this.sanitizer = sanitizer; } ngOnInit(): void {} getLink(){ return this.sanitizer.bypassSecurityTrustResourceUrl(this.youtubeVideoLink); } } <iframe width="420" height="315" [src]="getLink()" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

有点晚了,但是如果您使用本地应用程序客户端ID而不是web应用程序客户端ID,也会导致此错误。