简体   繁体   English

如何在 Firebase Auth 中添加或更新电话号码

[英]How to add or update phone_number in Firebase Auth

I am trying to add a phone number when a user is signing up using Firebase Auth.当用户使用 Firebase 身份验证注册时,我尝试添加电话号码。 I am using this method:我正在使用这种方法:

user = firebase.auth().createUserWithEmailAndPassword('myemail@email.com', 'password').catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // ...
});

And I am trying to update mobile number during the signup process using:我正在尝试使用以下方法在注册过程中更新手机号码:

if(user){
  user.updatePhoneNumber("+91999999999")
}

I am getting error:我收到错误:

updatePhoneNumber failed: First argument "phoneCredential" must be a valid phone credential.

I know it needs to be a valid phone number and according to this Answer we need to verify phone number to update.我知道它需要是一个有效的电话号码,根据这个答案,我们需要验证电话号码才能更新。

So my question is I need to create a signup form where I am getting phone email and PWD.所以我的问题是我需要创建一个注册表单,我可以在其中接收电话电子邮件和 PWD。

I want to save phone number and verify the number later.我想保存电话号码并稍后验证该号码。 Is there any way we can update phone number during signup.有什么办法可以在注册期间更新电话号码。

Using this code I can update phone_number in firebase admin:使用此代码,我可以在 firebase admin 中更新 phone_number:

user = auth.create_user(
    email='user@example.com',
    email_verified=False,
    phone_number='+15555550100',
    password='secretPassword',
    display_name='John Doe',
    photo_url='http://www.example.com/12345678/photo.png',
    disabled=False)

Why there is no function like this in web signup.为什么网络注册中没有这样的功能。

There is no way to set a phone number for a user without signing them in with/verifying that number.如果不使用该号码登录/验证用户,则无法为用户设置电话号码。 You will have to sign in the user with phone authentication too, and then link the two providers together .您还必须使用电话身份验证登录用户,然后将两个提供商链接在一起

If you don't want to sign the user in with their phone number, but merely want to store that number, you will have to do so outside of Firebase Authentication's built-in phone number provider.如果您不想让用户使用他们的电话号码登录,而只想存储该号码,则必须在 Firebase 身份验证的内置电话号码提供程序之外执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 firebase.auth (js, ts) 中更新用户电话号码 - how to update user phone number in firebase.auth (js, ts) 如何使用从 firebase 存储的 Auth uid 并更新 Auth 用户信息,例如更改密码、email 和电话号码? - How to use Auth uid that store from firebase and update Auth user information such as change password, email and phone number? 选择 phone_number 属性 On Button Click - Pick phone_number attribute On Button Click 我如何使用 firebase auth 在 nodejs 的服务器端验证用户电话号码 - How can i authenticate user phone number on server side in nodejs with firebase auth Javascript:电话 firebase 身份验证:如何放置 email? - Javascript: Phone firebase auth: How to put email? Firebase 当前用户更新电话号码 - Firebase current user update Phone Number 从Firebase身份验证ui电话号码身份验证系统保存已验证的电话号码 - save verfied phone number from firebase auth ui phone number authentication system 从Firebase ui auth电话号码身份验证系统保存用户确认的电话号码 - save users confirmed phone number from firebase ui auth phone number authentication system Firebase 和 React Auth 如何更新用户信息 - Firebase and React Auth how to update user information 如何在启用电话身份验证的情况下导出firebase用户帐户 - How to export firebase user account with phone Auth enabled
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM