12

I want to show different screens based on which connected app is used to login to Salesforce. Can the login flow somehow know which connected app is used?

There are multiple Login Flow variables we can leverage, but none of those contain the connected app.

None of the following seem useful for this scenario (source):

  • LoginFlow_LoginType – This variable allows you to designate a user type for Flow/Org.
  • LoginFlow_IpAddress – This variable acts as a user’s IP address. Through this variable, you have the power to delegate an IP address for a user, profile and other user-related fields.
  • LoginFlow_UserAgent – This variable stands as the user’s browser string. It also allows you to keep users from using Internet
    Explorer to log into your Org.
  • LoginFlow_Platform – This variable shows you what kind of system (i.e. Mac OSX) your users are logging in from.
  • LoginFlow_Application – Similar to the above variable; however, it shows what kind of device your users log in from (i.e. iPhone, tablet, desktop, etc.) so that you’ll know what finish location to relocate them to.
  • LoginFlow_Community – This variable shows what Community your user is currently in, if applicable. LoginFlow_SessionLevel – This variable is responsible for security and either works in high or standard assurance.
  • LoginFlow_UserId – This variable functions to display character IDs (up to 18 characters long) and also allows you to Lookup your user(s) and search the system to find similar fields.
  • Will a single user be assigned to log into your org from more than one connected app? Also, will they be logging in using SSO or will they be using their UserId/PW? – crmprogdev Jan 12 at 12:39
  • Yes, they can use multiple connected apps to login. Salesforce is the Identity Provider, so they can use their Salesforce username/password or Facebook or Google Auth Providers. – Folkert Jan 14 at 8:41
  • Does this apply for ALL Users (internal & external) or only for Community Users? If only to Community Users, I can provide a solution. If for all users, you may be out of luck. – crmprogdev Jan 16 at 13:53
  • Only community users. We use the Community Login license for IdP – Folkert Jan 17 at 9:47
4
+50

You may be in luck. There's something call the ExperienceID or expid that potentially could be used to do what you want to achieve. Its primary purpose is to be able to customize the "branding experience" for customers depending on where they are sent to your community from.

You can learn more about it by reading this link to the Salesforce External Identity Implementation Guide and also by reading Change Your Users’ Login Experience with Dynamic Branding from the Winter 18 Release Notes. If you associate each connected app with a different expid, it would seem to me that you could use it accomplish what you want with your Connected Apps by assigning each app a unique expid.

The ExperienceID can then be used to extend an endpoint using one of two different strategies as shown below.

Extend the following endpoints with expid_value.

  • community-url/services/oauth2/authorize/expid_value
  • community-url/idp/endpoint/HttpPost/expid_value
  • community-url/idp/endpoint/HttpRedirect/expid_value

Extend the following endpoints with expid={value}.

  • community-url_login_page?expid={value}
  • community-url/CommunitiesSelfReg?expid={value}
  • community-url/.well-known/auth-configuration?expid={value}

Pass in a different expid value to the self-registration page to deliver a different registration flow for each brand.

The experience ID value is captured in a cookie rather than in the URL. For example, if the expid_value is set to Customers, an associated cookie has the expid_Customers value.

  • 1
    pretty clever answer – cropredy Jan 18 at 1:50
  • The question them comes to "how to access the expid in a login flow?" – Fernando Gavinho Jan 18 at 10:06
  • @FernandoGavinho It depends on whether you've passed it in a cookie or as part of the expid value that can be held in a Community User's Profile. You could also use it as a start parameter for your login flow since you've used it to extend the log-in endpoint. It would appear that you'd have many options depending on how you pass it from your connected app. – crmprogdev Jan 18 at 22:11
  • In my use case I use the SSO endpoint "community-url/idp/endpoint/HttpPost/expid_value". However, I don't know how to access this value in the flow. I could if it was a visualforce page, but is there a way do access them on the flow? Maybe naming a variable for input only? I tryed "expid" and "ExpId", but it does not seem to work. – Fernando Gavinho Jan 21 at 9:14
  • Found it. To access the expId in the Login Flow you need to call the System.Site.getExperienceId() method. This can be done in the controller if it's a Visualforce Page or in an InvocableMethod if it's a visual flow. – Fernando Gavinho Jan 22 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.