Firebase authWithOAuthRedirect()的灾难 [英] Firebase authWithOAuthRedirect() woes

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

问题描述

我尝试更新我的angularjs应用程序以支持Firebase 1.1(我坚持使用Firebase 1.0.x)。
它弃用firebasesimplelogin,包括Firebase核心内的身份验证。
$ b

我已经能够使用

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

它接受一个回调,它在 authData

相反,我不能解释如何使用

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

Firebase身份验证文档页面非常简洁... :-(。这是所有的说:

或者,您可以提示用户使用完整浏览器重定向登录,而当您返回到原始页面时,Firebase将自动恢复会话。 b
$ b

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

解决方案

通过直接在ref上注册一个监听器(在调用 authWithOAuthRedirect 之前),可以使用authData。



<$ p $函数(authData){
...
}
ref.authWithOAuthRedirect(google,function(error){...} );

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


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.

I have been able to successfully implement authentication using

authWithOAuthPopup("<provider>", function(error, 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 Authentication docs page is very concise... :-(. This is all what is said:

Alternatively [instead of authWithOAuthPopup], you may prompt the user to login with a full browser redirect, and Firebase will automatically restore the session when you return to the originating page

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

解决方案

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) { ... });

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

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

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