Firebase authWithOAuthRedirect() 问题 [英] Firebase authWithOAuthRedirect() woes

查看:14
本文介绍了Firebase authWithOAuthRedirect() 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更新我的 angularjs 应用以支持 Firebase 1.1(我一直坚持使用 Firebase 1.0.x).
它弃用了 firebasesimplelogin,包括 Firebase 核心内部的身份验证.

I'm trying to update my angularjs app to support Firebase 1.1 (I was stick with Firebase 1.0.x).
It deprecates firebasesimplelogin, including authentication inside Firebase core.

我已经能够使用

authWithOAuthPopup("<provider>", function(error, authData) { ... });

它接受一个回调,它在authData中传递认证数据.

It accepts a callback, which is passed authentication data in authData.

相反,我不明白如何使用

On the contrary, I can't undersand how to use

authWithOAuthRedirect("<provider>", function(error) { ... });

Firebase 身份验证文档页面非常简洁...... :-(.这个就是这么说的:

Firebase Authentication docs page is very concise... :-(. This is all what is said:

或者 [而不是 authWithOAuthPopup],您可以提示用户使用完整的浏览器重定向登录,Firebase 将在您返回原始页面时自动恢复会话

当 Firebase - 重定向后 - 返回到我的页面时,我如何获取 authData?

How do I get authData, when Firebase - after redirection - returns to my page?

推荐答案

authData 可通过直接在 ref 上注册侦听器来获得(因此在调用 authWithOAuthRedirect 之前).

The authData is available by registering a listener directly on the ref (so before calling authWithOAuthRedirect).

ref.onAuth(function(authData) { 
    ... 
} 
ref.authWithOAuthRedirect("google", function(error) { ... });

参见 https://www.firebase.com/docs/web/guide/user-auth.html#section-monitoring-authentication

这篇关于Firebase authWithOAuthRedirect() 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆