【发布时间】:2014-06-05 08:58:16
【问题描述】:
我正在尝试通过我的网络应用程序构建 Google Plus 登录,就像您通过 oauth 弹出窗口在foursquare.com 上看到的一样。应用程序在控制台中显示以下错误。
未捕获的安全错误:阻止了来源为“http://airus.com:3000”的框架访问来源为“https://accounts.google.com”的框架。请求访问的帧具有“http”协议,被访问的帧具有“https”协议。协议必须匹配。
<script type="text/javascript">
var REDIRECT = 'http://airus.com/users/auth/google_oauth2/callback';
function login(url, x) {
var win = window.open(url, "windowname1", 'width=400, height=600');
var pollTimer = window.setInterval(function() {
console.log(win.document.URL);
if (win.document.URL.indexOf(REDIRECT) != -1) {
window.clearInterval(pollTimer);
var url = win.document.URL;
win.close();
x.reload();
}
}, 500);
}
$("#link").click(function(){
x = location;
login($(this).attr('href'), x);
return false;
})
</script>
知道怎么解决吗?
【问题讨论】:
标签: javascript oauth