在Firebase Auth#onAuthStateChanged上获取Facebook/Google访问令牌? [英] Get Facebook/Google access token on Firebase Auth#onAuthStateChanged?

查看:52
本文介绍了在Firebase Auth#onAuthStateChanged上获取Facebook/Google访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用Auth#signInWithPopup进行身份验证,则会得到具有凭据的结果.

If I authenticate using Auth#signInWithPopup I get a result having credentials.

如何在Auth#onStateChanged的观察者内部获取相同的凭据?

How can I get the same credentials inside the observer for Auth#onStateChanged?

推荐答案

您无法从Auth#onStateChanged获取凭据.您只能从Auth#signInWithPopup或Auth#getRedirectResult的结果中获取它们.由于这些字段仅在登录时获得一次,并且不由Firebase Auth维护或存储(例如,OAuth凭证,其他IdP数据),因此它们仅在登录完成后返回.

You can't get the credentials from Auth#onStateChanged. You can only get them from the result of Auth#signInWithPopup or Auth#getRedirectResult. As these fields are only obtained once on sign-in and not maintained or stored by Firebase Auth (eg. OAuth credential, additional IdP data), they are only returned on sign-in completion.

这篇关于在Firebase Auth#onAuthStateChanged上获取Facebook/Google访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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