Firebase getIdToken返回对象 [英] Firebase getIdToken returns object
本文介绍了Firebase getIdToken返回对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 redux-saga 和 redux-saga-firebase 库以集成
I am using redux-saga and redux-saga-firebase library to integrate firebase with redux-sagas. The problem is when I sign in a user, for example with signInWithEmailAndPassword
and even connect channel
to get the signed user and track user changes, I am not able to get correct token. getIdToken
, getIdTokenResult
methods just return objects with the following representation:
{
a: 0
b: qb {a: null, g: ƒ, b: ƒ, f: undefined, next: null, …}
c: A {a: 0, i: undefined, c: A, b: qb, f: qb, …}
f: qb {a: null, g: ƒ, b: ƒ, f: undefined, next: null, …}
g: false
h: false
i: undefined
}
这是代码:
function* loginSaga({ payload: { email, password } }) {
try {
yield call(
reduxSagaFirebase.auth.signInWithEmailAndPassword,
email,
password,
);
} catch (error) {
yield put(loginFailure(error));
}
}
function* loginStatusWatcher() {
const channel = yield call(reduxSagaFirebase.auth.channel);
while (true) {
const { user } = yield take(channel);
if (user) {
yield put(loginSuccess());
} else {
console.log('Put logout action here');
}
}
}
我在做什么错了?
推荐答案
getIdToken返回一个承诺,请确保您使用 getIdToken().then((token)=> console.log(token))代码>
getIdToken returns a promise, make sure you use getIdToken().then((token) => console.log(token))
这篇关于Firebase getIdToken返回对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文