Firebase电话身份验证失败 [英] Firebase phone Authentication failes

查看:58
本文介绍了Firebase电话身份验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用电话验证"进行Firebase登录.在开发过程中,我无法访问设备&Apple开发人员帐户,因此我使用

来实现此功能

reCAPTCHA验证

但是出现以下错误

{错误":{代码":403,消息":此ios客户端的请求应用程序被阻止.,"错误:[{"消息:"来自这个ios客户端应用程序是被阻止.," domain:" global," reason:" forbidden}]," status:" PERMISSION_DENIED}}}

我已经实现了它,如文档中所示.

下面是AppDelegate.swift中的代码:

  func应用程序(_应用程序:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey:任何]?)->布尔{//应用程序启动后进行自定义的替代点.FirebaseApp.configure()返回真}//对于iOS 9+func application(_ application:UIApplication,打开url:URL,选项:[UIApplicationOpenURLOptionsKey:Any])->布尔{如果Auth.auth().canHandle(url){返回真}返回假//与验证不相关的网址,开发人员应进行处理.} 

下面是ViewController.swift中的代码:

  @IBAction func didTapSignUp(_ sender:Any){PhoneAuthProvider.provider().verifyPhoneNumber("+ 919637892151",uiDelegate:nil){(verificationId,错误)在如果让错误=错误{//它总是来这里打印(error.localizedDescription)}如果让verifyId = VerificationId {打印(verificationId)UserDefaults.standard.set(verificationId,forKey:"authVerificationID")}}} 

解决方案

我遵循了此答案,并且有效./p>

将Google控制台中的API密钥密钥限制设置为无""

我很困惑,因为如果只有NONE起作用,它的目的是什么?

I wanted to do Firebase Login using Phone Auth. As I am developing and I don't have an access to device & Apple developer account, so I went to implement this feature using

reCAPTCHA verification

but I get this following error

{"error":{"code":403,"message":"Requests from this ios client application are blocked.","errors":[{"message":"Requests from this ios client application are blocked.","domain":"global","reason":"forbidden"}],"status":"PERMISSION_DENIED"}}

I have implemented that as it has been shown in the documentation.

Below is the code from AppDelegate.swift:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    FirebaseApp.configure()
    return true
}

// For iOS 9+
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
    if Auth.auth().canHandle(url) {
        return true
    }
    return false
    // URL not auth related, developer should handle it.
}

Below is the code from ViewController.swift:

@IBAction func didTapSignUp(_ sender: Any) {
    PhoneAuthProvider.provider().verifyPhoneNumber("+919637892151", uiDelegate: nil) { (verificationId, error) in
        if let error = error {
            // It always comes here
            print(error.localizedDescription)
        }
        if let verificationId = verificationId {
            print(verificationId)
            UserDefaults.standard.set(verificationId, forKey: "authVerificationID")
        }
    }
}

解决方案

I followed this answer and it works.

"set the API key Key restriction in Google Console to NONE"

I'm perplexed though because what is the purpose of it if only NONE works?

这篇关于Firebase电话身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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