Linking User Accounts

MongoDB Stitch provides multiple ways for you to integrate user authentication into your apps. For this reason, you may want to provide a way for your users to link their account from one provider with another.

For example, suppose you have an app that enables users to authenticate using Google or Facebook, but also allows anonymous log in. New users of your app will choose to explore the app’s functionality as an anonymous user. After working with the app for a while, a user decides that they want to perform an action that requires them to create an account. The user logs in using their Google credentials, and your app can link the data from their anonymous session to their account by using Stitch’s user-linking feature.

To provide user account linking in your code, use the linkWithCredential method of the StitchUser class. Documentation for this method can be found in the SDKs: