Link User Identities - Android SDK

MongoDB Realm provides multiple ways for users to log into your application. Because each method of authentication corresponds to a unique user identity, Realm lets you merge multiple identities corresponding to a single user into one user identity.

For instance, consider an application that enables users to authenticate via anonymous authentication so they may explore functionality without linking to an existing SSO provider or generating a new password. When that user decides to finally create a full account with an SSO provider or email/password authentication, you need some way of persisting the user's original anonymous identity with their new permanent identity.

You can link identities using the linkCredentials() or linkCredentialsAsync() methods of the User object of a logged in user.

user.linkCredentialsAsync(Credentials.emailPassword(email, password)) { result ->
if (result.isSuccess) {
Log.v("EXAMPLE", "Successfully linked existing user identity with email/password user: ${result.get()}")
} else {
Log.e("EXAMPLE", "Failed to link user identities with: ${result.error}")
Give Feedback