Loading
Upcoming Mandatory Changes to Public Key Infrastructure (PKI)Read More
Salesforce Enforces New Security Requirements in Summer 2026Read More
Get Started with B2C Commerce
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Configure the Auth Provider in the Sandbox Org

          Configure the Auth Provider in the Sandbox Org

          Before you begin, have the consumer key and secret generated by the external client available for the B2C Commerce Merchant Agent.

          1. In the Salesforce sandbox org, create the Registration Handler Apex Class.
            1. At the top of the page, click Setup and select Setup.
            2. In the Quick Find box, enter Apex Classes, and then select Apex Classes.
            3. Click New.
            4. Create the B2CRegistrationWrapper class by copying and pasting the following code in the class editor.
              global class B2CRegistrationWrapper implements Auth.RegistrationHandler {
                  /**
                   * Instantiates the standard B2C Commerce handler to delegate the logic.
                   */
                  private Auth.B2CCommerceCloudRegistrationHandler getStandardHandler() {
                      return new Auth.B2CCommerceCloudRegistrationHandler();
                  }
                  global User createUser(Id portalId, Auth.UserData data) {
                      // You can add custom pre-processing logic here
                      // Delegate to the standard handler
                      return getStandardHandler().createUser(data);
                  }
                  global void updateUser(Id userId, Id portalId, Auth.UserData data) {
                      // You can add custom logging or attribute mapping here
                      // Delegate to the standard handler
                      getStandardHandler().updateUser(userId, data);
                  }
              }
          2. Save your changes.
            This Apex class acts as a wrapper around the standard B2C Commerce registration handler. You can add custom pre-processing logic or attribute mappings as needed.
          3. In the Quick Find box, enter Auth Providers, and then select Auth Providers.
          4. Click New.
          5. Configure the Auth Provider by entering the field values in the following table.
            Field Value
            Provider Type Salesforce
            Name Enter a descriptive name for the Auth Provider.
            Consumer Key From the Salesforce IdP org, navigate to the External Client App, select the Settings tab, and then locate the Consumer Key in OAuth Settings.
            Consumer Secret From the Salesforce IdP org, navigate to the External Client App, select the Settings tab, and then locate the Consumer Secret in OAuth Settings.
            Authorize Endpoint URL https://idp-org-hostname/services/oauth2/authorize
            Token Endpoint URL https://idp-org-hostname/services/oauth2/token
            Registration Handler Type Apex
            Registration Handler B2CRegistrationWrapper class
            Execute Registration As Select a user with the System Administrator role
          6. Click Save.
          7. Copy the generated Callback URL.
            The Auth Provider also generates a single sign-on URL for users to access the sandbox org.
          8. Log in to the primary IdP org and open the external client app that you created earlier.
          9. Paste the Callback URL into the external client app's Callback URL field.
          10. Save the changes.
           
          Loading
          Salesforce Help | Article