【发布时间】:2019-09-30 20:56:34
【问题描述】:
我已将以下测试 https.onCall 函数部署到 firebase 上的 Cloud Functions - 使用节点 10 部署:
export const helloWorld = functions.https.onCall((data, context) => {
return {
"message": "Hello, world",
}
});
从节点环境测试时,此函数按预期返回。
但是,在我的颤振 (android) 应用程序中 - 使用 Cloud functions plugin for Flutter,我收到以下身份验证错误,尽管已登录(通过电话号码身份验证):
颤振代码:
void _checkAuth() async {
print("Check auth");
final FirebaseAuth _auth = FirebaseAuth.instance;
var user = await _auth.currentUser();
print(user.toString());
_testFunCall();
}
void _testFunCall() async {
HttpsCallable callable = CloudFunctions.instance
.getHttpsCallable(functionName: 'helloWorld');
try {
final HttpsCallableResult result = await callable.call();
print(result.data);
} on CloudFunctionsException catch (e) {
print('caught firebase functions exception');
print(e.code);
print(e.message);
print(e.details);
} catch (e) {
print('caught generic exception');
print(e);
}
}
错误:
I/flutter ( 4662): caught firebase functions exception
I/flutter ( 4662): UNAUTHENTICATED
I/flutter ( 4662): Unauthenticated
I/flutter ( 4662): null
有什么想法吗?
【问题讨论】:
-
在用户使用 firebase 登录后调用这个 _checkAuth() 方法。那么只有你可以得到 _auth.currentUser();否则用户将为零且仅未经身份验证。
-
我在 2020 年 4 月的最新插件中遇到了这个确切的错误,还有其他人吗?
-
这里也一样。你找到解决办法了吗?
-
这也发生在我的团队身上。我们使用节点 12。这仍然是一件事吗?
-
“节点”中的相同问题:“14”
标签: android firebase flutter google-cloud-functions