2
votes

By following the information on this link, I am currently working on trying to create a user using Firebase, as shown in the code below. However, it appears no user is created when the app is run. Any input is greatly appreciated. The Firebase URL was taken from my test database.

let ref = Firebase(url: "https://test-96df2.firebaseio.com")
    ref.createUser("[email protected]", password: "correcthorsebatterystaple",
                   withValueCompletionBlock: { error, result in
                    if error != nil {
                        // There was an error creating the account
                        print("error creating account")
                    } else {
                        let uid = result["uid"] as? String
                        print("Successfully created user account with uid: \(uid)")
                    }
    })

Edit:

The propagated error is:

Error Code: AUTHENTICATION_DISABLED) Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/

However, as shown below, the email/password authentication is enabled in the Firebase console. enter image description here

1
debug it and take a look at the error object. it should have more details regarding the error.adolfosrs
what firebase version are you using?adolfosrs
I'm not entirely sure which version of firebase I am using, but I believe the most recent one.sBourne
Your code appears to be Firebase 2.x but the console is the new one associated with Firebase 3.xJay

1 Answers

2
votes

You have already authorized the email registration as I can see in your screenshot. So the problem doesnt realies on AUTHENTICATION_DISABLED.

From your error message and the snippet code I can see that you have created a new project but you are trying to use the legacy firebase SDK and so you will have compatibility issues. Also, you are looking into the old firebase documentation.

First of all you will need to make sure you have configured your project as documented in new firebase start guide.

After, you can take a look at the documentation for creating a new user with the new sdk. You can find the 3.x create user call bellow.

FIRAuth.auth()?.createUserWithEmail(email, password: password) { (user, error) in
  // ...
}