Firebase phone Authentication failes

梦想的初衷 提交于 2020-12-15 06:32:02

问题


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")
        }
    }
}

回答1:


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?



来源:https://stackoverflow.com/questions/51062724/firebase-phone-authentication-failes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!