Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Error handling during single sign-on

Learn how to identify and resolve common single sign-on errors in Scalekit, ensuring a seamless authentication experience for your users

Reference of error codes and how to handle them. For step-by-step fixes of the errors developers hit most often while adding Modular SSO, see Troubleshoot Modular SSO.

When users attempt to log in via single sign-on (SSO) using Scalekit, any issues encountered will result in error details being sent to your application’s redirect URI via the error and error_description query parameters. Proper error handling ensures a better user experience.

Scalekit sends an SSO error to the redirect_uri of the sign-in request, the same URL that receives the authorization code on success. The redirect carries error, error_description and the state value from your authorization URL. If the redirect_uri is missing or isn’t one of your registered redirect URLs, Scalekit can’t redirect and shows the user an error page instead.

Errors from IdP-initiated sign-in have no sign-in request to return to, so Scalekit sends them to your initiate-login URL with the same error and error_description parameters.

Errors don’t have a per-connection destination, but you choose the redirect_uri and state on every sign-in request, so your callback knows which organization the user was signing in to. Use that to show an error page that fits the organization and tells its users how to fix the problem.

  • Look up the organization from state. When you build the authorization URL, store the organization ID in the user’s server-side session next to the random state value. In your callback, verify state matches, read the organization ID from the session, and render that organization’s error page.
  • Or use a redirect URL per organization. Register a separate redirect URL for each organization, such as https://app.example.com/sso/callback/acme, and pass it as redirect_uri on that organization’s sign-in requests.

Keep state unguessable and verify it on every callback, including error callbacks. Don’t put the organization ID in state in place of the random value: state protects the callback from cross-site request forgery.

If there is any issue between Scalekit and your application, the following errors may occur:

ErrorError descriptionPossible resolution strategy
invalid_redirect_uri
Redirect URI is not part of the pre-approved list of redirect URIsAdd the valid URL in the Scalekit dashboard before using it
invalid_connection_selector
The authorization URL has no organization_id, connection_id, domain or login_hint, or the one it has doesn’t match an organization, connection or domain in this environmentPass one of these parameters, with an ID from the same environment as your API credentials. See Troubleshooting
no_active_connections
There are no active SSO connections configured to process the single sign-on requestEnsure active SSO connections are set up
connection_not_active
The configured connection is not activeEnable the SSO connection in the Scalekit dashboard
no_configured_connections
No active SSO connections configuredEnsure active SSO connections are set up
invalid_organization_id
Invalid organization IDVerify and use a valid organization ID
invalid_connection_id
Invalid connection IDVerify and use a valid connection ID
domain_not_found
No domain specified for the SSO connection(s)Check domain configuration in Scalekit dashboard
invalid_user_domain
User’s domain not allowed for this SSO connectionEnsure user domain is part of the allowed domains list
invalid_client
The client application is not recognized or not configured correctlyVerify the client_id value in your authorization URL
application_not_active
The application is inactiveEnable the application in the Scalekit dashboard
invalid_request
The authorization request contains invalid or missing parameters, such as no scopeReview the authorization URL parameters
invalid_idp_initiated_sso
A user started from their IdP’s dashboard, and the environment has no initiate login URLBuild an initiate login endpoint and register it under Authentication > Redirect URLs
unauthorized
The request is unauthorizedVerify that valid credentials are being used
user_not_active
The user account is inactiveActivate the user account or contact the IT admin
server_error
actual error description from the serverThis must be a rare occurrence. Please reach out to us via your private slack channel or via email

If SSO configuration issues arise, you will encounter the following errors:

Error codeError descriptionPossible resolution strategy
mandatory_attribute_missing
Missing mandatory user attributesEnsure all the mandatory user attributes are configured properly
invalid_id_token
Invalid ID tokenCheck the identity provider’s functioning
failed_to_exchange_token
Token exchange failure due to incorrect client_secretUpdate the client_secret with the correct value
user_info_retrieve_failed
User info retrieval failed, possibly due to an incorrect client_secret or other issuesUpdate the client_secret with the correct value. If unsuccessful, investigate further. Please reach out to us via your private slack channel or via email
invalid_saml_metadata
Scalekit couldn’t use the IdP’s SAML metadata or certificate. A common cause is an expired IdP signing certificateCheck the metadata URL is correct and reachable. If the connection uses a manually entered certificate, enter the IdP’s current signing certificate. See Certificate expiry and rotation
invalid_saml_response
Invalid SAML responseReview and fix SAML configuration settings
invalid_in_response_to
The SAML response doesn’t match a login started in this browser, for example because an embedded web view dropped cookies or two logins ran at onceOpen SSO logins in the system browser, one at a time. See Troubleshooting
invalid_saml_request
The SAML request is invalidCheck the SAML configuration in both Scalekit and the identity provider
invalid_saml_form_params
The SAML form parameters are invalid or malformedReview the SAML response format from the identity provider
signature_validation_failed
Failed signature validationReview and update the ACS URL in the identity provider’s settings
invalid_acs_url
Invalid ACS URLReview and update the ACS URL in the identity provider’s settings
invalid_assertion_url
The assertion URL in the SAML request is invalidVerify and update the ACS URL in the identity provider’s settings
invalid_status
Invalid statusReview and update the SAML configuration settings in the identity provider
malformed_saml_response
Marshalling errorEnsure SAML response is properly formatted
assertion_expired
Expired SAML assertionWe received an expired SAML assertion. This could be because of clock skew between the identity provider’s server and our servers. Please reach out to us via your private slack channel or via email
response_expired
Expired SAML responseWe received an expired SAML response. This could be because of clock skew between the identity provider’s server and our servers. Please reach out to us via your private slack channel or via email
authentication_not_completed
The authentication flow was not completedEnsure the user completes the login process in the identity provider
user_login_required
User login is required to continueRedirect the user to the login page to complete authentication

These errors come from exchanging the code for the user’s profile, not from the redirect to your callback URL. The SDK throws an error that carries Scalekit’s JSON response, such as {"error":"invalid_grant","error_description":"invalid code"}.

ErrorError descriptionPossible resolution strategy
invalid_grant
invalid codeThe code was already used or isn’t valid. Exchange each code once; if an exchange fails, start a new login
invalid_grant
redirect_uri does not correspondPass the same redirect URI to the code exchange as to the authorization URL
invalid_client
invalid client_id / client_secretUse the client ID and secret from the same environment
invalid_scope
invalid scope offline_access not allowedRemove offline_access from the scopes. Modular SSO doesn’t issue refresh tokens