简体   繁体   English

使用 FirebaseAuth 电话号码验证进行测试

[英]Testing with FirebaseAuth Phone Number verification

In my app we only have phone number verification for signing in. This works flawlessly for the users, but are starting to get a bit painfull when it gets to testing the application.在我的应用程序中,我们只有用于登录的电话号码验证。这对用户来说完美无缺,但是在测试应用程序时开始变得有点痛苦。

There are multiple problems:有多个问题:

  1. Phone number verification only works on a physical device.电话号码验证仅适用于物理设备。
  2. Signing in multiple times causes a big delay in receiving SMS with verification code.多次登录会导致接收带有验证码的短信有很大的延迟。 Often I end up not receiving a message at all.通常我最终根本没有收到消息。
  3. Google thinks that this is suspicious activity and will disable the account after too many attempts of logging in. Google 认为这是可疑活动,会在多次尝试登录后禁用该帐户。

Is there any way to solve this?有没有办法解决这个问题? Some kind of debug option to test this more easily?某种调试选项可以更轻松地进行测试?

See this section of the Firebase Phone Auth docs.请参阅 Firebase 电话身份验证文档的这一部分 Firebase provides a way to add "whitelisted" numbers for testing purposes. Firebase 提供了一种添加“白名单”号码以进行测试的方法。 From the docs, these phone numbers do not eat up your usage quota, do not require sending an actual text message and can run consecutive tests on the same phone number without getting throttled.从文档中可以看出,这些电话号码不会占用您的使用配额,不需要发送实际的短信,并且可以对同一个电话号码进行连续测试而不会受到限制。

I tried to use my own phone number until I read this:我试着用我自己的电话号码,直到我读到这个:

Make sure you use fictional numbers that do not already exist.确保使用尚不存在的虚构数字。 Firebase Authentication does not allow you to whitelist existing phone numbers used by real users. Firebase 身份验证不允许您将真实用户使用的现有电话号码列入白名单。 One option is to use 555 prefixed numbers as US test phone numbers, for example: +1 650-555-3434一种选择是使用 555 前缀号码作为美国测试电话号码,例如:+1 650-555-3434

Looks like you'll need a new phone and take a break from testing for a bit.看起来您需要一部新手机并暂时停止测试。
This is straight from Firebase docs:这直接来自 Firebase 文档:

To prevent abuse, Firebase enforces a limit on the number of SMS messages that can be sent to a single phone number within a period of time.为防止滥用,Firebase 对一段时间内可以发送到单个电话号码的 SMS 消息数量实施了限制。 If you exceed this limit, phone number verification requests might be throttled.如果超过此限制,电话号码验证请求可能会受到限制。 If you encounter this issue during development, use a different phone number for testing, or try the request again later.如果您在开发过程中遇到此问题,请使用不同的电话号码进行测试,或稍后重试该请求。

At the bottom of this section在本底部

用新的手机号码试试,不要添加已经注册的号码。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM