Link User with multiple provider Type

Hi,

In my application we have users who signed up using Google auth or Email/Password. But now I am facing an issue. If any existing user who signed up Email/password if try to sign in with Google login, new user id getting created. I am looking for an option to avoid creating multiple user and link user having same user id by different provider type. I went through documentation and got to know about linkCredentials() function but I guess that’s only applicable if user is authenticated.

Please suggest some solution for this, I tried switching to other auth providers but even if I try to authenticate, new id will be created since provider type is different.