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.
Where Scalekit sends errors
Section titled “Where Scalekit sends errors”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.
Show an organization-specific error page
Section titled “Show an organization-specific error page”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 randomstatevalue. In your callback, verifystatematches, 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 asredirect_urion 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.
Integration related errors
Section titled “Integration related errors”If there is any issue between Scalekit and your application, the following errors may occur:
| Error | Error description | Possible resolution strategy |
|---|---|---|
invalid_redirect_uri | Redirect URI is not part of the pre-approved list of redirect URIs | Add 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 environment | Pass 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 request | Ensure active SSO connections are set up |
connection_not_active | The configured connection is not active | Enable the SSO connection in the Scalekit dashboard |
no_configured_connections | No active SSO connections configured | Ensure active SSO connections are set up |
invalid_organization_id | Invalid organization ID | Verify and use a valid organization ID |
invalid_connection_id | Invalid connection ID | Verify 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 connection | Ensure user domain is part of the allowed domains list |
invalid_client | The client application is not recognized or not configured correctly | Verify the client_id value in your authorization URL |
application_not_active | The application is inactive | Enable the application in the Scalekit dashboard |
invalid_request | The authorization request contains invalid or missing parameters, such as no scope | Review the authorization URL parameters |
invalid_idp_initiated_sso | A user started from their IdP’s dashboard, and the environment has no initiate login URL | Build an initiate login endpoint and register it under Authentication > Redirect URLs |
unauthorized | The request is unauthorized | Verify that valid credentials are being used |
user_not_active | The user account is inactive | Activate the user account or contact the IT admin |
server_error | actual error description from the server | This must be a rare occurrence. Please reach out to us via your private slack channel or via email |
SSO configuration related errors
Section titled “SSO configuration related errors”If SSO configuration issues arise, you will encounter the following errors:
| Error code | Error description | Possible resolution strategy |
|---|---|---|
mandatory_attribute_missing | Missing mandatory user attributes | Ensure all the mandatory user attributes are configured properly |
invalid_id_token | Invalid ID token | Check the identity provider’s functioning |
failed_to_exchange_token | Token exchange failure due to incorrect client_secret | Update the client_secret with the correct value |
user_info_retrieve_failed | User info retrieval failed, possibly due to an incorrect client_secret or other issues | Update 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 certificate | Check 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 response | Review 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 once | Open SSO logins in the system browser, one at a time. See Troubleshooting |
invalid_saml_request | The SAML request is invalid | Check the SAML configuration in both Scalekit and the identity provider |
invalid_saml_form_params | The SAML form parameters are invalid or malformed | Review the SAML response format from the identity provider |
signature_validation_failed | Failed signature validation | Review and update the ACS URL in the identity provider’s settings |
invalid_acs_url | Invalid ACS URL | Review and update the ACS URL in the identity provider’s settings |
invalid_assertion_url | The assertion URL in the SAML request is invalid | Verify and update the ACS URL in the identity provider’s settings |
invalid_status | Invalid status | Review and update the SAML configuration settings in the identity provider |
malformed_saml_response | Marshalling error | Ensure SAML response is properly formatted |
assertion_expired | Expired SAML assertion | We 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 response | We 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 completed | Ensure the user completes the login process in the identity provider |
user_login_required | User login is required to continue | Redirect the user to the login page to complete authentication |
Code exchange errors
Section titled “Code exchange errors”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"}.
| Error | Error description | Possible resolution strategy |
|---|---|---|
invalid_grant | invalid code | The 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 correspond | Pass the same redirect URI to the code exchange as to the authorization URL |
invalid_client | invalid client_id / client_secret | Use the client ID and secret from the same environment |
invalid_scope | invalid scope offline_access not allowed | Remove offline_access from the scopes. Modular SSO doesn’t issue refresh tokens |