iOS上Chrome中"不支持"的Facebook OAuth重定向方法的正确位置是什么

What is the correct location for redirection method for Facebook OAuth “Unsupported” in Chrome on iOS fix?

本文关键字:quot 方法 位置 是什么 重定向 OAuth Chrome 不支持 iOS Facebook      更新时间:2023-09-26

我有这部分代码,它解决了当你使用Parse.com JavaScript 的Facebook登录工作流时,用户的Facebook身份验证的Chrome移动问题

https://parse.com/docs/js/guide#users-facebook用户

// fix iOS Chrome
    if( navigator.userAgent.match('CriOS') )
        window.open('https://www.facebook.com/dialog/oauth?client_id='+490518664444605+'&redirect_uri='+ document.location.href +'&scope=email,public_profile', '', null);
    else
        Parse.FacebookUtils.logIn(null, {
            //scope: 'email,public_profile'
        });

此解决方法的来源可以在此处找到https://parse.com/docs/js/guide#users-facebook用户

我无法理解的是,我可以在哪里插入此修复现有代码?我已经尝试了代码块中的几个位置,但到目前为止,我还无法实现想要的结果

能给我一个建议吗?

现有代码

    //check user session and refresh it
    var uri = encodeURI('http://xxxxcom/home.html');
    FB.getLoginStatus(function(response) {
        if (response.status === 'connected') {
            //user is authorized
            document.getElementById('loginBtn').style.display = 'none';
            getUserData();
        } else {
            //user is not authorized
        }
    });
};
//load the JavaScript SDK
(function(d, s, id){
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

//add event listener to login button
document.getElementById('loginBtn').addEventListener('click', function() {
    //do the login
var uri = encodeURI('http://xxxxx.com/home.html');
Parse.FacebookUtils.logIn(null, {
    success: function(user) {
        if (!user.existed()) {
                window.location.href=uri;
        } else {
            window.location = encodeURI("https://www.facebook.com/dialog/oauth?client_id=xxxxxxx&redirect_uri="+uri+"&response_type=token");

        }
    },
    error: function(user, error) {
    }

});

}, false);

我得到了一个在谷歌chrome中登录ios facebook网站的解决方案。事实上,问题出在ios中的谷歌chrome上,当我们点击facebook登录按钮时,它会在内部为ios chrome中的window.open提供null。
有两种解决方案-
首先-检查它在ios(chrios(中是否为chrome,然后生成自定义登录屏幕(我们仍然不可能纠正它(
第二个-我使用了什么。是使用脸书从反手登录创建一个api点击将填充脸书屏幕,然后当登录完成时,它将重定向到你的服务器,从那里你将重定向到带有脸书数据的网站页面
它的另一个好处是,你可以为同一网站所有者创建两个网站(你不能在facebook开发者帐户中设置两个网站url(。通过这种方式,你可以用相同的facebook appid创建多个网站的facebook登录名。

相关文章: