iOS上的Chrome上的Facebook OAuth“不支持”

Facebook OAuthpopup窗口仅在iOS上的Chrome中发生错误。 这两个developers.facebook.com和谷歌都没有提到这一点。 想法?

ios上的移动设备上的facebook oath弹出窗口的屏幕截图

您可以使用下面的redirect方法(通过检测用户代理为chrome ios):

https://www.facebook.com/dialog/oauth?client_id={app-id}&redirect_uri={redirect-uri} 

在这里查看更多信息https://developers.facebook.com/docs/facebook-login/login-flow-for-web-no-jssdk/

备注:我personnaly在这种情况下使用服务器OAuth,但这应该做的伎俩,很简单

这就是我做的(专门修复iOS chrome)

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

这是一个完整的解决scheme,您的FB JS的Auth在Chrome iOS问题 http://seanshadmand.com/2015/03/06/facebook-js-login-on-chrome-ios-workaround/

JSfunction检查身份validation,手动打开FB身份validation页面,完成后刷新原始页面上的身份validation令牌:

 function openFBLoginDialogManually(){ // Open your auth window containing FB auth page // with forward URL to your Opened Window handler page (below) var redirect_uri = "&redirect_uri=" + ABSOLUTE_URI + "fbjscomplete"; var scope = "&scope=public_profile,email,user_friends"; var url = "https://www.facebook.com/dialog/oauth?client_id=" + FB_ID + redirect_uri + scope; // notice the lack of other param in window.open // for some reason the opener is set to null // and the opened window can NOT reference it // if params are passed. #Chrome iOS Bug window.open(url); } function fbCompleteLogin(){ FB.getLoginStatus(function(response) { // Calling this with the extra setting "true" forces // a non-cached request and updates the FB cache. // Since the auth login elsewhere validated the user // this update will now asyncronously mark the user as authed }, true); } function requireLogin(callback){ FB.getLoginStatus(function(response) { if (response.status != "connected"){ showLogin(); }else{ checkAuth(response.authResponse.accessToken, response.authResponse.userID, function(success){ // Check FB tokens against your API to make sure user is valid }); } }); } 

和FBauthentication的开放处理程序转发并调用刷新到主页面。 请注意,Chrome中的window.open有错误,所以如上所述正确调用它:

 <html> <head> <script type="text/javascript"> function handleAuth(){ // once the window is open window.opener.fbCompleteLogin(); window.close(); } </script> <body onload="handleAuth();"> <p>. . . </p> </body> </head> </html> 

我的2分钱这个答案是没有人知道的。 我点击一个button点击loginjs对话框,所以现在当它是铬ios我首先检查,如果用户login到Facebook,如果没有,我把它们发送到login窗口。 这个问题是,如果用户没有loginFacebook,聊天室用户需要点击连接button两次。 如果他们login到Facebook一键就足够了。

  $( 'body' ).on( 'click', '.js-fbl', function( e ) { e.preventDefault(); if( navigator.userAgent.match('CriOS') ) { // alert users they will need to click again, don't use alert or popup will be blocked $('<p class="fbl_error">MESSAGE HERE</p>').insertAfter( $(this)); FB.getLoginStatus( handleResponse ); } else { // regular users simple login try { FB.login( handleResponse , { scope: fbl.scopes, return_scopes: true, auth_type: 'rerequest' }); } catch (err) { $this.removeClass('fbl-loading'); } } }); 

这段代码使它适用于Chrome用户。 在处理响应我简单照顾fb响应,并将其发送到我的网站后端login/注册用户。

 var handleResponse = function( response ) { var $form_obj = window.fbl_button.parents('.flp_wrapper').find('form') || false, $redirect_to = $form_obj.find('input[name="redirect_to"]').val() || window.fbl_button.data('redirect'); /** * If we get a successful authorization response we handle it */ if (response.status == 'connected') { var fb_response = response; /** * Make an Ajax request to the "facebook_login" function * passing the params: username, fb_id and email. * * @note Not all users have user names, but all have email * @note Must set global to false to prevent gloabl ajax methods */ $.ajax({...}); } else { //if in first click user is not logged into their facebook we then show the login window window.fbl_button.removeClass('fbl-loading'); if( navigator.userAgent.match('CriOS') ) window.open('https://www.facebook.com/dialog/oauth?client_id=' + fbl.appId + '&redirect_uri=' + document.location.href + '&scope=email,public_profile', '', null); } }; 

希望能帮助到你!

不是一个真正的答案,但基于这个线程值得注意的是,开始为我们的应用程序工作,在Chrome上,当我们在iPhone上General>Reset>Reset Location & Privacy

我在google chrome上find了一个ios facebook网站login的解决scheme。 其实这个问题是在谷歌浏览器在iOS中,当我们点击Facebook的loginbutton,它给内部为null到window.open在ios铬。
两个解决scheme,要么检查它是在铬(chrios)铬,然后生成自定义login屏幕(仍然没有机会,我们会纠正)。
其次是我用过的。 是使用反手脸书login创build一个API命中将填充脸书屏幕,然后当login完成后,它将redirect到您的服务器从您将redirect到您的网站页面与Facebook数据。
另一个好处是,你创build2个网站的同一个网站所有者,你不能在Facebook开发者帐户中设置两个网站的url。这样,你可以创build许多网站Facebooklogin与相同的Facebook的appid。

这是所有开发人员在实现FBloginfunction时遇到的一个非常普遍的问题。 我已经尝试了大部分的互联网解决scheme,但都没有工作。 window.opener不能在Chrome iOS中使用,或者在使用/dialog/oauth时候某个时候FB对象没有被加载。

最后,我尝试所有的黑客之后,我自己解决这个问题!

 function loginWithFacebook() { if( navigator.userAgent.match('CriOS') ) { var redirect_uri = document.location.href; if(redirect_uri.indexOf('?') !== -1) { redirect_uri += '&back_from_fb=1'; } else { redirect_uri += '?back_from_fb=1'; } var url = 'https://www.facebook.com/dialog/oauth?client_id=[app-id]&redirect_uri='+redirect_uri+'&scope=email,public_profile'; var win = window.open(url, '_self'); } else { FB.login(function(response) { checkLoginState(); }, { scope:'public_profile,email,user_friends,user_photos' }); } } 

注意,上面我传递了一个额外的参数到redirecturl,所以一旦新的窗口打开上面的redirecturi我可以读取值,可以说是这个调用是从Chrome的iOS窗口。 还要确保这个代码在页面加载时运行。

 if (document.URL.indexOf('back_from_fb=1') != -1 && document.URL.indexOf('code=') != -1) { pollingInterval = setInterval(function() { if(typeof FB != "undefined") { FB.getLoginStatus(function(response) {}, true); checkLoginState(); } else { alert("FB is not responding, Please try again!", function() { return true; }); } }, 1000); }