[英]Using both Google Signin and Firebase auth require login twice?
我遇到了一些令人困惑的问题:
我在我的应用程序Firebase
来存储用户数据等,并保护用户的数据我使用Google Authentication
的构建。 我认识到我可以在这个signIn过程中定义scopes
,用户可以/应该允许,但我注意到你不能要求所有的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
:请参阅https://www.firebase.com/docs/web/api/firebase/authwithoauthtoken.html 。 从那里:
此方法接受OAuth凭据的单个字符串参数(例如OAuth 2.0承载访问令牌)或对象(例如一组OAuth 1.0a凭证)。 使用OAuth令牌登录Facebook,GitHub和Google只需要一个字符串访问令牌:
// 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令牌。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.