Docs Menu
Docs Home
/ /
Atlas Device SDKs
/ /

Link User Identities - Kotlin SDK

On this page

  • Example

Realm provides many authentication providers to log users into your app. Each provider creates a unique user identity. Realm lets you merge multiple credentials into one user identity.

Credentials must be linked prior to logging a user in. Once credentials are used to login a user, you cannot link that credential anymore. Also, you cannot link multiple email/password credentials together.

Consider an application that offers anonymous login, which allows users to explore the app without registering. If a user wants to continue using the application, they can create a permanent account by using another authentication provider. Realm creates a new User object. The app can then link the new identity with the current user.

Note

Depending on how you have configured email/password authentication, there may be additional steps (confirming the email address, for example) before the new account is created and can be linked.

You link identities using linkCredentials. This links the new user identity to the logged-in User.

val app: App = App.create(YOUR_APP_ID) // Replace this with your App ID
runBlocking {
val user = app.login(Credentials.anonymous()) // logs in with an anonymous user
// registers an email/password user
app.emailPasswordAuth.registerUser(email, password)
// links anonymous user with email/password credentials
user.linkCredentials(Credentials.emailPassword(email, password))
}

Back

Manage Email/Password Users

On this page