We have moved some apps to SSO and it has affected our automations. Here is how I solved the Microsoft SSO sign-in process with the Parallel activity.
I found that depending upon the exact situation, one of these 3 prompts appears:
Here is our plan:
- Get credentials for the user
- Open the browser to a URL and log into the Microsoft prompts
- When the “Pick an account” prompt appears:
a. Click the account from step 1
b. If the account isn’t already listed in the prompt, click “Use another account” - When the “Sign in” prompt appears:
a. Enter the username
b. Click Next - When the “Enter password prompt” appears:
a. Enter the password
b. Click “Sign in”
I’ll skip step 1, you know how to get credentials
The rest of the steps are just this, the Parallel makes it very simple:
I recommend setting the timeout the same for all three main Check App States. I’ve been using 30 seconds and haven’t had an issue. Could probably even shorten it a bit to shave some time.
The “Pick an account” prompt is the most complicated one. It contains another Check App State that checks if our desired account is already listed, if not then click “Use another account”:
The “Sign in” prompt is very simple:
Notice neither of the first two top level Check App States has a “does not appear” section. Don’t need it - just do what we need to do when those prompts do appear.
The third one - Enter password - does have a “does not appear” section so this is where you end up if none of the prompts appears. For my purposes I just need it to log and move on, exiting the Parallel and continuing the process.
Here is a breakdown of the “Enter password/Target appears” section.
Enter the password (I found that Hardware events was necessary for typing the password) and then click Sign In. If the “Stay signed in” prompt appears I click No but for your purposes you may want to click Yes.
Instead of using a Check App State to see if the “Stay signed in” prompt appears, I just set the Click activity to “continue on error” and a 5 second timeout.
I noticed that in Chrome, sometimes it circles back around and makes you click the account one more time, so I added this:
The reason I have “chrome.exe” in a variable is I built this into a library and an argument allows you to configure which browser it uses. Then I just put it into all the selectors as a variable.
And now the most important part of the Parallel activity - the Condition:
I just set it as a variable CompletionCondition (boolean):
So at the very end after we have entered the password and clicked Sign in, we simply set CompletionCondition to True and the Parallel exits.
Remember when I said I added this to a library? Here is what the activity looks like when I use it in another automation:
The best part is now when I need to open a web app in one of my automations, I can put this activity inside another Parallel:
The Check App State on the right verifies that the login succeeded and then sets the completion condition:
So now if the Microsoft Sign in prompts appear, they’re handled - but if we are just logged in with cached credentials it immediately stops checking for the Microsoft Sign in prompts and continues. And if none of that happens, we throw a login exception.