我已经部署了以下测试https.onCall
函数到 Firebase 上的 Cloud Functions - 使用节点 10 部署:
export const helloWorld = functions.https.onCall((data, context) => {
return {
"message": "Hello, world",
}
});
从节点环境测试时,此函数按预期返回。
但是,在我的 flutter(android)应用程序中 - 使用Flutter 的云函数插件 https://github.com/flutter/plugins/tree/master/packages/cloud_functions,尽管已登录(通过电话号码身份验证),但我收到以下身份验证错误:
颤振代码:
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);
}
}
Error:
I/flutter ( 4662): caught firebase functions exception
I/flutter ( 4662): UNAUTHENTICATED
I/flutter ( 4662): Unauthenticated
I/flutter ( 4662): null
有任何想法吗?
问题在于部署到云功能时使用 Node 10。
Node 10 目前处于测试阶段。切换到节点 8 并且工作正常:
In package.json
在您的云功能目录中,切换:
"engines": {
"node": "10"
},
to:
"engines": {
"node": "8"
},
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)