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.
- Root Cause 2: OKTA certificate not installed in Personal store in Orchestrator server.
- Install Okta Signing Certificate into the Personal store in Orchestrator server:
- Restart IIS by opening a CMD as admin and running "IISRESET" for changes to take effect.
- Refresh page from browser. Issue would be resolved.
- Review Step 2 here for more information.