0

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")
        }
    }
}
ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
Anirudha Mahale
  • 2,526
  • 3
  • 37
  • 57

1 Answers1

2

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?

Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
  • 1
    This is not the correct solution. You shouln't remove your key security. Unfortunately there is not a clean solution because it looks like a Google Auth issue. – FrizzTheSnail Jul 20 '22 at 10:57
  • @FrizzTheSnail "This is not the correct solution" and "Unfortunately there is not a clean solution" doesn't resolve the problem – Lance Samaria Jul 20 '22 at 15:25
  • @FrizzTheSnail From Google Docs: "*This flow also requires your **API Key to be unrestricted** or allowlisted*". Read the reCAPTCHA section https://firebase.google.com/docs/auth/android/phone-auth. Even Google itself says it. – Lance Samaria May 19 '23 at 00:16