Kotlin registration problems

I’m attempting to setup authentication. As reference, I’m mostly looking to https://docs.mongodb.com/realm/tutorial/android-kotlin/#enable-authentication
I’m running into some trouble with that tutorial.

First off, it seems that .emailPassword has been deprecated in favor of .emailPasswordAuth

So, I switch to something like this…
taskApp.emailPasswordAuth.registerUser(email, password)
or
taskApp.emailPasswordAuth.registerUserAsync(email, password)

But I’m getting a ‘Name already in use’ error. The error is also showing up in my realm.mongoDB logs

I’ve set up registration successfully with realm synch on Android before. I seem to remember that the registerUser functions were not working correctly, and that I ultimately had to switch to set up a token system and switch to JWT authentication in order to get registration working.

Is that android-kotlin tutorial still valid? What’s the most efficient way to get authentication working with android-kotlin?

Where is the indicator that the property emailPassword is deprecated? As far as I can see it should still be valid from https://realm.io/docs/java/10.0.1/api/io/realm/mongodb/App.html#getEmailPassword--

The Name already in use error indicates that the user is already registered. Maybe you have a pending user registration or something alike. Try inspecting the Realm App users according to https://docs.mongodb.com/realm/users/create

Hi Claus, thanks for the reply.

The indication for me that emailPassword is deprecated comes from attempting to access the method in android studio. If I try to access the property as demonstrated in the Kotlin tutorial I linked, It comes up as an unresolved reference in Android Studio.

I cloned the tutorial app separately and I did not have the same problem for whatever reason. The taskApp object that I set with the same code from the tutorial, does have the emailPassword property.
taskApp = App(
AppConfiguration.Builder(BuildConfig.MONGODB_REALM_APP_ID)
.build())I gave up and just switched back to my original pattern using Credentials.jwt("<token>")

So I guess it’s something with my project, but I’ve given up and gone pack to using JWT authentication for now.

I solved a portion of this issue. A major challenge here is that tutorial code is frequently outdated.

But the error I was receiving is not related to this, or any issue with Realm, but an issue with my server code.

I’m using Mongoose via a node backend. I’m also using mongoose-unique-validator to ensure a unique email for each user. It turns out that this validation fails on db access errors. So my backend was receiving db access errors, but they were manifesting as ‘Name already in use’ errors.

I discovered that my database user, found under Atlas > Database Access did not have the correct permissions, breaking several of my database interactions. Editing my user to change ‘database user permissions’ to ‘atlas admin’ resolved the errors.

My server code had been functional previously. So not sure what happened there.