Meteor Social Login - Blank page on oauth2 login using Facebook or Google

纵饮孤独 提交于 2019-12-24 00:32:41

问题


I am working on a mobile app using Meteor and Facebook or Google login.

On Android devices it works great.

But on iOS devices I get a blank page after successful authentication.The user has to click on a "Done" button to close the page and get the app regain control.

Meteor version 1.3.4.4 and latest accounts-facebook, accounts-google packages.

This is the code I am using for login:

//Oauth login with Facebook.
this.loginFB = function() {
  Meteor.loginWithFacebook({
   requestPermissions: ['email', 'public_profile'],
   redirectUrl: Meteor.absoluteUrl('_oauth/facebook')
  }, function(err){
    if( err.error === 'Email exists.' ) {
      if (Meteor.isCordova) {

      } else {

      }
    }
  });
};

//Oauth login with Google.
this.loginGoogle = function() {
  Meteor.loginWithGoogle({
    requestPermissions: ['email', 'profile'],
    redirectUrl: Meteor.absoluteUrl('_oauth/google')
  }, function(err){
    if( err.error === 'Email exists.' ) {
      if (Meteor.isCordova) {

      } else {

      }
    }
  });
};

回答1:


I find solution of this bug wery long time, but i found this staff.... meteor add cordova:cordova-plugin-inappbrowser@https://github.com/ephemer/cordova-plugin-inappbrowser.git#04091fde737519c149e7ad6316971cb6b490c5b3 and it helps me, and i think it helps you =)




回答2:


When creating your iOS hybrid app using Meteor, the latter uses Cordova and the Cordova plugin InAppBrowser.

That plugin is used when presenting the 3rd party OAuth service (whether Facebook, Google, GitHub or whatever), very probably so that the new page does not have access to the local app Cordova API.

Unfortunately, there was a "bug" in that plugin when used in such a configuration, see [CB-11136]:

InAppBrowser fails to close with WKWebView OAuth

Launching InAppBrowser from Cordova iOS Platform 4+ with its WKWebView for OAuth (e.g. Facebook or Google login) fails to close as it should.

The reason is that the entire WKWebView thread seems to pause when another view controller is presented. This can be confirmed by inspecting the WKWebView session in Safari, running window.open('http://something.com') and then trying to enter another command into that Safari console.

This entirely explains why the underlying app cannot take control back and close that new window, but everything works fine when user manually presses the "DONE" button (in particular, access tokens are correctly retrieved and user gets logged in into the app).

This has been fixed as of plugin version 1.7.0.

Manually upgrading the InAppBrowser plugin version to 1.7.0 or later fixes the issue on iOS Cordova packaged apps for all tested OAuth login services:

meteor add cordova:cordova-plugin-inappbrowser@1.7.1

(You can browse to the Cordova Plugins registry to find the latest available release)



来源:https://stackoverflow.com/questions/40105055/meteor-social-login-blank-page-on-oauth2-login-using-facebook-or-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!