---
schema_version: "1"
id: ad5ca51e7ac0a4dda08df7e9daf848a41d7ddc8b9457f9213ccf75aacecbd378
title: Configure SSO to a Salesforce IdP Production Org
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/cc/264-0-0/b2c_sso_idp_production_org.md
canonical_url: https://help.salesforce.com/s/articleView?id=cc.b2c_sso_idp_production_org.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 443b9e35dae238d166687dd181f41a75fa9a1ad90da110ef4d0d72eafb95d164
description: If the B2C instance connects to a Salesforce production org, configure a login flow for the Merchant Agent work. No Auth Provider setup is required.
products:
  - Commerce
  - B2C Commerce
release: "264"
---
# Configure SSO to a Salesforce IdP Production Org

If the B2C instance connects to a Salesforce production org, configure a login flow for the Merchant Agent work. No Auth Provider setup is required.

## Configure a Login Flow at the Primary Salesforce Org

To synchronize a user's identity between B2C Commerce and the Salesforce org IdP, configure a login flow at the primary Salesforce org. When a user logs in to the Salesforce IdP org, this flow handles the synchronization.

1. Log in to the primary Salesforce org acting as the IdP.
2. Create the Login Flow invocable action.
    1. At the top of the page, click ![Setup](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-cc-b2c_merchandiser_administrator-264-0-0-production-enus/ea76f372-6cfa-42a6-8e7c-05c6df7abed8/cc/b2c_merchandiser_administrator/images/setup_icon_no_border.png) and select **Setup**.
    2. In the Quick Find box, enter and select **Apex Classes**.
    3. Click **New**.
    4. Copy this code and paste it into the Apex Class editor.
        
        ```
        /**
                 * Invocable action for the login flow to synchronize the merchant's
                 * identity between the Commerce Cloud and the Core Identity Provider.
                 */
                 public class CommerceIdentitySyncAction {
                 @InvocableMethod(
                 label='Sync Commerce Identity'
                 description='Establishes the mapping between the logged-in core user and the ECOM user.'
                 category='Identity'
                 )
                 public static List<ActionResult> execute() {
                 List<ActionResult> results = new List<ActionResult>();
                 ActionResult result = new ActionResult();
                 try {
                 // Invoke the system identity synchronization logic
                 Auth.CommerceIdentitySynchronizationAction.UserSynchronizationResult syncStatus =
                 Auth.CommerceIdentitySynchronizationAction.establishUserSynchronization();
                 if (syncStatus != null) {
                 result.isSuccess = syncStatus.isSuccess;
                 result.errorMessage = syncStatus.errorMessage;
                 }
                 } catch (Exception ex) {
                 // Catching any unexpected issues to prevent the Login Flow from breaking
                 result.isSuccess = false;
                 result.errorMessage = 'An unexpected error occurred during identity sync: ' + ex.getMessage();
                 }
                 results.add(result);
                 return results;
                 }
                 /**
                 * Captures the status of the synchronization for use in Flow decision elements.
                 */
                 public class ActionResult {
                 @InvocableVariable(label='Is Success' description='True if the identity mapping was created successfully.')
                 public Boolean isSuccess;
                 @InvocableVariable(label='Error Message' description='The reason the synchronization failed, if applicable.')
                 public String errorMessage;
                 }
                 }
        ```
    5. Click **Save**.
3. Create and assign the login flow in Salesforce IdP org.
    1. In the Quick Find box, find and select **Flows**.
    2. Click **New**, and then select **Screen Flow**.
    3. Between **Screen Flow Start and End**, click the **+** button, and then select **Action**.
    4. Search for the action **Sync Commerce Identity**.
    5. Select the action and provide a **Label** and **API Name**.
    6. Click **Save**.
    7. Click **Activate**, and then exit Flow Builder.
4. In the Quick Find box, enter and select **Login Flows**.
5. Click **New**, and enter the field values in the table.
    
     
    | Field | Value |
    | --- | --- |
    | Type | Flow |
    | Flow | Select the flow that you created. |
    | User License | Salesforce |
    | Profile | Standard User |
6. Save your changes.