Epic Games Reconcile Lambda
On this page
When an Epic Games identity provider is used to complete a federated login request, FusionAuth will use the configured linking strategy to reconcile the user. FusionAuth will attempt to match the user information returned from the Epic Games identity provider to an existing user account or create a new one.
You may optionally utilize a lambda to customize the user and user registration during the authentication event.
When you create a new lambda using the FusionAuth Admin UI, you will be provided an empty function to implement.
Starting in version 1.65.0, you can use attribute mappings to map IdP claims directly to FusionAuth user and registration fields without writing a lambda. Reconcile lambdas and attribute mappings are mutually exclusive. Attempting to configure both on a given IdP results in a validation error.
Lambda Structure#
When you create the lambda with the API, give the function the following signature:
function reconcile(user, registration, userInfo, context) {
// Lambda code goes here
}
This lambda must contain a function named reconcile that accepts the following parameters:
user: the FusionAuth User object. You can modify this object. However, you can't change the email or username attributes after FusionAuth links the user.registration: the FusionAuth UserRegistration object. You can modify this object.
userInfo: the response from the Epic Account Services accounts API. This object is read-only.context: Available since1.64.0an object containing the context of the request, including access to secrets. This object is read-only.
The User API and Registration API documentation describe the user and registration objects.
The userInfo object is an array that holds one account. The account has an accountId, a displayName, a preferredLanguage, and a linkedAccounts array of the platforms linked to the Epic account. FusionAuth uses displayName as the username. Epic Games doesn't return an email address.
Example Lambda#
The following lambda stores the Epic account Id, display name, and linked platforms in user.data.epic. When the user has no preferred language, the lambda copies the Epic preferred language to the user.
// stores the Epic account and the platforms linked to it
function reconcile(user, registration, userInfo, context) {
var account = userInfo[0];
user.data = user.data || {};
user.data.epic = {
accountId: account.accountId,
displayName: account.displayName,
linkedPlatforms: (account.linkedAccounts || []).map(function (linked) {
return linked.identityProviderId;
})
};
// keep a language the user already chose
if (account.preferredLanguage && !(user.preferredLanguages && user.preferredLanguages.length)) {
user.preferredLanguages = [account.preferredLanguage];
}
}Assigning The Lambda#
After you create the lambda, assign the lambda to the Epic Games identity provider.
Navigate to Settings -> Identity Providers . Select your existing Epic Games configuration. If you haven't configured Epic Games yet, click Add provider and select Epic Games.
Related
Learn how to map the data from an Apple login to a FusionAuth user and registration with a reconcile lambda.
Learn how to map the data from a Facebook login to a FusionAuth user and registration with a reconcile lambda.
Learn how to map the data from a Google login to a FusionAuth user and registration with a reconcile lambda.
Learn how to map the data from a LinkedIn login to a FusionAuth user and registration with a reconcile lambda.