Skip to main content

Salesforce

Follow these steps to add Salesforce as a social sign-in provider to your project using the Ory Console:

  1. Go to AuthenticationSocial Sign-In in the Ory Console.

  2. Click the switch next to the Salesforce logo to start the configuration.

  3. Copy the Redirect URI and save it for later use.

  4. Create an Salesforce Connected App, noting the following points:

    • Enable OAuth Settings
    • Paste the saved Redirect URI from Ory into the Callback URL field in the OAuth Settings of the connected app.
  5. In the Selected OAuth Scopes field, make sure openid, profile, and email are selected.

  6. Ensure the Require Proof Key for Code Exchange (PKCE) checkbox is disabled, as Ory Kratos does not support PKCE.

  7. Ensure the Require Secret for Web Server Flow checkbox is enabled. Screenshot of Salesforce Connected App OAuth Configuration (Jul 2024)

  8. Create the app.

  9. Go to the OAuth Settings of your newly created connected app, click on Manage Consumer Details and copy the following data to the corresponding fields in the form in the Ory Console:

    • Consumer Key (called Client ID in Ory)
    • Consumer Secret (called Client Secret in Ory)

    Screenshot of Salesforce Connected App indicating button to retrieve client ID and secret (Jul 2024)

  10. Copy the Salesforce top-level domain from the URL bar (typically https://mySalesforceTenant.my.salesforce.com) to the Tenant URL field of the form in the Ory Console.

  11. In the Data Mapping field of the form in the Ory Console, add the following Jsonnet code snippet, which maps the desired claims to the Ory Identity schema:

local claims = {
email_verified: false,
} + std.extVar('claims');

{
identity: {
traits: {
// Allowing unverified email addresses enables account
// enumeration attacks, if the value is used for
// verification or as a password login identifier.
//
// Therefore we only return the email if it (a) exists and (b) is marked verified
// by Salesforce.
[if 'email' in claims && claims.email_verified then 'email' else null]: claims.email,
username: claims.nickname,
},
},
}
danger

Don't save secrets such as API keys, credentials, or personal data directly in Jsonnet code snippets. Jsonnet code snippets used for data mapping aren't stored in an encrypted format in Ory Network.

  1. Click Save Configuration.

Troubleshooting

When you add a social sign-in provider, you can encounter common problems such as:

  • Redirect URI mismatch
  • Redirect loops during registration
  • Domain verification issues

To troubleshoot those issues, read Social sign-in troubleshooting.

Requested url does not match any rules

If you see this error after clicking on "Sign in with Salesforce", make sure that the "Tenant URL"/issuer_url is set correctly.