Firebase:有什么方法可以向Google登录的用户添加电话号码吗? [英] Firebase: Is there any way to add phone number to a google signed in user in flutter?

查看:31
本文介绍了Firebase:有什么方法可以向Google登录的用户添加电话号码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的flutter应用程序中使用firebase auth实现了Google登录.我想向已经使用Google应用程序登录过的用户添加电话号码.我已经尝试了电话身份验证.它创建了另一个,并替换了该应用程序中的现有用户.有什么方法可以将两者整合?

I have implemented the google sign in my flutter app using firebase auth. I want to add a phone number to the user who is already signed in in the app using google. I have tried the phone authentication. It created another and replaces the existing user from the app. Is there any ways to integrate both?

推荐答案

无法从客户端SDK中为Firebase身份验证用户设置电话号码,而无需对其进行验证.

There is no way to set a phone number for a Firebase Authentication user from the client-side SDKs without verifying it.

但是从受信任的环境(例如您的开发计算机,您控制的服务器或Cloud Functions)中,您可以使用一个Admin SDK来执行此操作.例如,有关更新用户的文档.您必须将此功能包装在自定义API中,然后从Flutter应用中调用它.

But from a trusted environment (such as your development machine, a server you control, or Cloud Functions), you can use one of the Admin SDKs to do this. The the documentation on updating a user for an example. You'd have to wrap this functionality in a custom API and call that from your Flutter app.

或者,您可以在云数据库(例如Cloud Firestore或Firebase Realtime Database)中存储用户的电话号码(和其他信息).实际上,这是存储有关用户配置文件的其他信息的最常用方法,因为您还可以从应用程序中查询此信息.

Alternatively, you can store the phone number (and other information) for a user in a cloud database, such as Cloud Firestore or Firebase Realtime Database. This is actually the most common way to store additional information about a user profile, as this way you can also query this information from the application.

这篇关于Firebase:有什么方法可以向Google登录的用户添加电话号码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆