首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Chrome on iOS修复中,Facebook OAuth“不支持”的重定向方法的正确位置是什么?

问在Chrome on iOS修复中,Facebook OAuth“不支持”的重定向方法的正确位置是什么?
EN

Stack Overflow用户
提问于 2015-07-07 03:11:52
回答 1查看 61关注 0票数 0

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

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

代码语言:javascript
复制
// 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-users中找到此解决方法的来源

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

有没有人能提个建议?

现有代码

代码语言:javascript
复制
    //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);
EN

回答 1

Stack Overflow用户

发布于 2016-02-26 01:15:21

我有一个在谷歌浏览器中登录ios facebook网站的解决方案。实际上,问题出在ios中的google chrome,当我们点击facebook的登录按钮时,issue中的window.open在内部显示为空。

有两种解决方案-

First-要么检查它是ios(chrios)中的chrome,然后生成自定义登录屏幕(仍然没有机会,我们会正确)。

Second-我用过的东西。是使用facebook登录,从反手创建一个api点击将填充facebook屏幕,然后当登录完成后,它将重定向到您的服务器,从那里您将重定向到您的网站页面与facebook数据。

的另一个好处是,它的是,你可以创建2个网站的同一网站所有者(你不能设置两个网站的网址在脸书开发者帐户) .In这种方式,你可以创建多个网站脸书登录与相同的脸书appid。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31253779

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档