MongoDB.live, free & fully virtual. Register Now MongoDB.live, free & fully virtual. Register Now

linkCredentials with an existing Google user

I’m calling app.currentUser.linkCredentials with Google credentials that are already hooked up to an existing user. I’m getting the error message “a user already exists with the specified provider” (which makes sense because it does). My question is how do I go about linking that existing user to the active user (I then expect to handle all the logic of merging the two realms in my application)? As an alternative, is there a way to check if there is already a user hooked up to that Google account, or do I have to wait for the error to be thrown?

You can only link identities, not users. This means that if a user has already authenticated with the Google identity, this identity can no longer be linked to a different user.

There’s no way to check if a user with a specified credential exists, so your only option currently is to handle the error.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.