同时使用 Google Signin 和 Firebase auth 需要登录两次?

Using both Google Signin and Firebase auth require login twice?

我 运行 遇到了一个对某些用户来说可能令人困惑的问题:

我在我的应用程序中使用 Firebase 来存储用户数据等并保护用户数据,我使用 Google Authentication 中的构建。我认识到我可以在此登录过程中定义 scopes,这是用户 can/should 允许的,但我注意到您不能要求所有 Google Scopes/Services ,(全部具有 Firebase 内置功能)

所以我还必须使用 Google JS Library 进行身份验证,以访问存储在 Google 上的其余用户数据(我想在我的 Web 应用程序中显示用户)。

如果 Google signin popup 显示 两次 ,一次授权给 Firebase,另一次授权给 Google API's,可能会有点混乱.

我的问题是,有没有办法,也许在 Firebase signin process 处交出 access_token(反之亦然),我没有用户登录 两次Google popup只出现一次?

您可以使用从 Google 获得的令牌调用 authWithOAuthToken auth:参见 https://www.firebase.com/docs/web/api/firebase/authwithoauthtoken.html。从那里:

This method accepts either a single string argument for OAuth credentials (such as an OAuth 2.0 bearer access token) or an object (such as a set of OAuth 1.0a credentials). Logging in with Facebook, GitHub, and Google with an OAuth token requires just a string access token:

// Authenticate with Facebook using an existing OAuth 2.0 access token
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
ref.authWithOAuthToken("facebook", "<ACCESS-TOKEN>", function(error, authData) {
  if (error) {
    console.log("Login Failed!", error);
  } else {
    console.log("Authenticated successfully with payload:", authData);
  }
});

文档中的示例使用 facebook,但这同样适用于 Google 令牌。