【发布时间】:2020-10-04 10:08:15
【问题描述】:
我在 Flutter 中构建的移动应用程序使用 google 登录来注册用户。在这个应用程序中,我使用 Cloud Functions Plugin for Flutter 调用 Firebase 云函数(称为 questionAnswer)。
如果我从 this 文档中正确理解,https 请求应自动包含用户的 Firebase 身份验证。
如何从 Cloud Function 中检索用户的身份验证信息?我需要它来访问 Firebase 云数据库中与该特定用户关联的数据。我应该在 https 请求中包含谷歌身份验证令牌作为参数吗?
这是我在 Flutter 应用中的代码:
final HttpsCallable callable = CloudFunctions.instance.getHttpsCallable(
functionName: 'questionAnswer',
);
fetchHttps() async {
dynamic resp = await callable.call();
print(resp);
}
这是云函数中的代码
exports.questionAnswer = functions.https.onCall(() => {
console.log('addNumbersLog', "holaLog");
return answer;
});
【问题讨论】:
标签: firebase flutter firebase-authentication google-cloud-functions