简体   繁体   English

Firebase 电话身份验证失败

[英]Firebase phone Authentication failes

I wanted to do Firebase Login using Phone Auth.我想使用电话身份验证进行 Firebase 登录。 As I am developing and I don't have an access to device & Apple developer account, so I went to implement this feature using由于我正在开发并且我无法访问设备和 Apple 开发人员帐户,因此我使用

reCAPTCHA verification reCAPTCHA 验证

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"}} {"error":{"code":403,"message":"来自该 ios 客户端应用程序的请求被阻止。","errors":[{"message":"来自该 ios 客户端应用程序的请求被阻止。", "domain":"global","re​​ason":"forbidden"}],"status":"PERMISSION_DENIED"}}

I have implemented that as it has been shown in the documentation.我已经实现了,正如文档中所示。

Below is the code from AppDelegate.swift:下面是来自 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:下面是来自 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" “将 Google Console 中的 API 密钥限制设置为 NONE”

I'm perplexed though because what is the purpose of it if only NONE works?我很困惑,因为如果只有 NONE 有效,它的目的是什么?

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

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