Google 登录 API 不适用于 Mozilla Firefox

Google sign in API does not work on Mozilla Firefox

我目前正在处理一个 Web 应用程序,该应用程序要求用户使用他们的 google 帐户登录才能访问核心功能。当使用 Google Chrome 时,一切都按照预期的方式工作:用户单击 "Sign In",弹出窗口打开 Google sign in form,用户登录,他会被转到主页面。 (好)

然而

使用 Mozilla Firefox 38.0.1 时,网络应用程序无法以任何方式使用,因为当用户单击 "Sign In" 时,它什么都不做。几乎什么都没有,甚至控制台上也没有错误。

这是登录按钮:

//head
<meta name="google-signin-client_id" content="{CLIENT ID}.apps.googleusercontent.com">

//body
<button class="g-signin2 login-button" data-onsuccess="onSignIn"></button>

Firefox 和 Google 登录 API 当前是否存在已知问题?

好的,找到了解决方案:我遵循了 this。基本上,我没有使用 Google SignIn 的简单集成,我只是创建了一个自定义处理程序和侦听器。我保留了原来的按钮,因为它是必需的,只是添加了这个 javascript:

HTML

<script src="https://apis.google.com/js/plus.js?onload=appStart"></script>

JS

//googleSignIn.js

var auth2; // The Sign-In object.
var googleUser; // The current user.
/**
 * Calls startAuth after Sign in V2 finishes setting up.
 */
var appStart = function() {
  console.log('appStart()')
  gapi.load('auth2', initSigninV2);
};
/**
 * Initializes Signin v2 and sets up listeners.
 */
var initSigninV2 = function() {
  auth2 = gapi.auth2.getAuthInstance({
      client_id: '{CLIENT ID}.apps.googleusercontent.com',
      scope: 'profile'
  });

  // Listen for sign-in state changes.
  auth2.isSignedIn.listen(signinChanged);
  // Listen for changes to current user.
  auth2.currentUser.listen(userChanged);

  // Sign in the user if they are currently signed in.
  if (auth2.isSignedIn.get() == true) {
      auth2.signIn();
  }
};
/**
 * Listener method for sign-out live value.
 *
 * @param {boolean} val the updated signed out state.
 */
var signinChanged = function (val) {
    console.log('Signin state changed to ', val);
};
/**
 * Listener method for when the user changes.
 *
 * @param {GoogleUser} user the updated user.
 */
var userChanged = function (user) {
  console.log('User now: ', user);
  googleUser = user;
};

$('.login-button').on('click', function() {
    console.log('signing in')

    auth2.signIn().then(function(user) {
        //callback to handle sign in
        onSignIn(user);
    });
})

我不确定是什么导致 Google 登录无法在 mozilla 上运行。如果有人知道这是一个已知问题,请在评论中告诉我。

底线: easy integration of Google Sign In did not work on Mozilla. Had to integrate using listeners.