小编dsg*_*g38的帖子

Firebase + Flutter - 云函数 onCall 导致 Android 应用程序出现“未经身份验证”错误

我已将以下测试https.onCall函数部署到 firebase 上的 Cloud Functions 中 - 使用节点 10 部署:

export const helloWorld = functions.https.onCall((data, context) => {

    return {
        "message": "Hello, world",
    }

}); 
Run Code Online (Sandbox Code Playgroud)

从节点环境中测试时,此函数按预期返回。

但是,在我的 flutter (android) 应用程序中 - 使用FlutterCloud 函数插件,尽管已登录(通过电话号码身份验证),但仍收到以下身份验证错误:

颤振代码:

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 …
Run Code Online (Sandbox Code Playgroud)

android firebase flutter google-cloud-functions

5
推荐指数
1
解决办法
1570
查看次数