function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pedro HPedro H 

Linking Third party social account with Auth.RegistrationHandler

Hello all,

we would like to link an existing Salesforce account to a social account (Google, Facebook,...) the first time the user uses this authentication provider. We don't want to use the "Existing User Linking URL" because it requires the user to be already looged in Salesforce.

I have seen in the documentation of the Auth.RegistrationHandler that the createUser method should return  the User object that corresponds to the third party’s user information and may be a new user that hasn’t been inserted in the database or may represent an existing user record in the database.  

To link the account we should use any attribute in the "Auth.UserData" to try to locate an existing user and return it in the createUser function. Is that correct?

Best regards.

 
Andy BoettcherAndy Boettcher
According to the documentation on Auth.UserData and createUser:

Returns a User object using the specified portal ID and user information from the third party, such as the username and email address. The User object corresponds to the third party’s user information and may be a new user that hasn’t been inserted in the database or may represent an existing user record in the database.

Yes, that is what you want to use.  You need to know the UserId beforehand.
Mounika VorugantiMounika Voruganti
Hi Pedro,

Did you find any solution ? Let me know.

I am working on the same POC.