I am trying to SSO into Salesforce via auth provider (Azure).

It works when I log in for the first time, but afterwards [Third-Party Account Link] record will be created and the following error will occur:

ErrorDescription = Required fields are missing: [Email]

If I delete [Third-Party Account Links] record and try again, the login is successful.

Is createUser only called in RegistrationHandler ? I have to fix registration handler as shown below to avoid the error in createUser(...) when it runs

// I cannot find key... The only thing I can know is identifier
global User createUser(Id portalId, Auth.UserData data){

    if(!canCreateUser(data)) {
        User u = [SELECT Id , Username FROM User WHERE username = 'user2@pulmuone.com' LIMIT 1];
        return u;

        //Returning null or throwing an exception fails the SSO flow
        //return null;

// It does not work
global void updateUser(Id userId, Id portalId, Auth.UserData data){
    User u = new User(id=userId);
    u.email = data.email;
  • You don't have to perform the update DML in your updateUser method. I suspect your data attribute is null. Can you debug it out – Bryan Anderson Nov 15 '19 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.