LinkedIn Reconcile Lambda

LinkedIn Reconcile lambda

When an LinkedIn identity provider is used to complete a federated login request FusionAuth will use the email address to reconcile user. You may optionally utilize a lambda to customize the user and user registration during this authentication event.

When you create a new lambda using the FusionAuth UI we will provide you an empty function for you to implement.

If you are using the API to create the lambda you will need to ensure your function has the following signature:

function reconcile(user, registration, linkedInUser) {
  // Lambda code goes here

This lambda must contain a function named reconcile that takes three parameters. The parameters that the lambda is passed are:

  • user - the FusionAuth User object. You can modify this, except the email or username attribute may not be modified after the user has been linked.
  • registration - the FusionAuth UserRegistration object. You can modify this.
  • linkedInUser - the JSON payload returned by the LinkedIn Email and Me APIs. This is read-only.

The two FusionAuth objects are well documented here in the User API and Registration API documentation. The linkedInUser may contain various user claims depending upon the user’s LinkedIn configuration and the scopes requested in the LinkedIn configuration.

Assigning the lambda

Once a lambda is created, you may assign it to the LinkedIn identity provider in the IdP configuration.

Navigate to Settings -> Identity Providers and select your existing LinkedIn configuration or click Add provider and select LinkedIn if it has not yet been configured.

Default lambda

A default LinkedIn reconcile lambda is available in FusionAuth that may be used or modified. The default LinkedIn lambda function is documented below.

// This is the default LinkedIn reconcile, modify this to your liking.
function reconcile(user, registration, linkedInUser) {
  // Un-comment this line to see the linkedInUser object printed to the event log
  //, null, ' '));

  user.firstName = linkedInUser.localizedFirstName || user.firstName;
  user.lastName = linkedInUser.localizedLastName || user.lastName;

  // LinkedIn returns several images sizes.
  // See
  var images = linkedInUser.profilePicture['displayImage~'].elements || [];
  var image100 = images.length >= 1 ? images[0].identifiers[0].identifier : null;
  var image200 = images.length >= 2 ? images[1].identifiers[0].identifier : null;
  var image400 = images.length >= 3 ? images[2].identifiers[0].identifier : null;
  var image800 = images.length >= 4 ? images[3].identifiers[0].identifier : null;

  // Use the largest image.
  if (images.length > 0) {
    user.imageUrl = images[images.length];

  // Record the LinkedIn Id = || {}; =;