Error When Trying To Use Okta Authentication-StatusCode-500-InternalServerError-Sequence Contains No Elements

Error when trying to use Okta Authentication: {"StatusCode":500,"StatusDescription":"InternalServerError","Message":"Sequence contains no elements"}.

Issue: Sometimes, after configuring OKTA for SSO authentication for the Orchestrator instance, one may run into the following error while attempting SSO login:

{"StatusCode":500,"StatusDescription":"InternalServerError","Message":"Sequence contains no elements"}.


Diagnosis, Root Cause and Resolution:

  • Firstly, review the Application Event Logs. Expect to see something like the following:

UiPath.IdentityServer.Web.Middleware.ExceptionHandlinqMiddleware Sequence contains no elements InvalidOperationException*Sequence contains no elements* at System.Ling.ThrowHelper.ThrowNoElementsExceptionatSystem.Ling.Enumerable.FirstTSourcel(IEnumerable'1source)at Sustainsys.Saml2.Configuration.IdentityProviderDictionary.get_Item(Int32i)at Sustainsys.Saml2.Configuration.Identity ProviderDictionary.get_Default) at Sustainsys.Saml2.WebSso.SignInCommand.Run(Entityld idpEntityld, String returnPath, HttpRequestData request, lOptions options, Dictionary 2 relayData) at Sustainsys.Saml2.AspNetCore2.Saml2Handler.ChallengeAsync(AuthenticationPropertiesproperties)

This error usually comes from the "IdentityService" source and indicates that the Identity Server is unable to authenticate using the provided credentials.

  • Root Cause 1: SAML parameters configured incorrectly.
Resolution: Make sure you've followed: Orchestrator - Okta Authentication (uipath.com), and that all parameters are correct in the SAML Setup Page within Orchestrator.
  • Root Cause 2: OKTA certificate not installed in Personal store in Orchestrator server.
Resolution:
  1. Install Okta Signing Certificate into the Personal store in Orchestrator server:
  2. Restart IIS by opening a CMD as admin and running "IISRESET" for changes to take effect.
  3. Refresh page from browser. Issue would be resolved.
  4. Review Step 2 here for more information.