Skip to content

Errors

rakomi_flutter never throws across its public API for expected failure conditions — sign-in, refresh, and MFA failures all surface as AuthState.error(SdkError(...)), either as the return value of the call or as an item on authStateChanges. The one exception is programmer error (an invalid constructor argument, or calling an unsupported method the wrong way) — those throw synchronously, because they indicate a bug in the calling code, not a runtime condition to branch on.

if (state is AuthStateError) {
final SdkError error = state.error;
switch (error.code) {
case SdkErrorCode.invalidCredentials:
case SdkErrorCode.signInFailed:
// show "invalid email or password"
break;
case SdkErrorCode.networkError:
// show "network error, try again"
break;
case SdkErrorCode.mfaStepUpRequired:
// switch to the TOTP step; error.errorMessage carries the challengeId
break;
default:
// generic fallback
}
}

SdkError carries code (SdkErrorCode), reason (SdkErrorReason, a finer-grained discriminator), an optional errorMessage, an optional providerError (from an OAuth provider’s callback), and an optional cause. Any bearer token or JWT-shaped substring inside errorMessage/providerError is redacted before toString()/toJson() renders it, so it is safe to log an SdkError’s string form.

CodeMeaning
refreshFailedThe refresh-token exchange failed (see reason for why).
oauthCallbackErrorThe OAuth callback carried an error, or failed validation.
tenantSuspendedThe tenant is suspended.
csrfMismatchThe OAuth state parameter did not match the persisted value.
codeExchangeFailedThe authorization-code-for-token exchange failed.
signInFailedA password sign-in/sign-up attempt failed.
invalidConfigThe SDK was misconfigured.
networkErrorA network-level failure (no response, or an unexpected non-2xx).
providerErrorThe identity provider itself returned an error.
biometricErrorA biometric unlock attempt failed — see reason.
storageErrorPersisting to secure storage failed.
rateLimitedThe request was rate-limited.
invalidCredentialsThe submitted credentials were rejected.
mfaStepUpRequiredPrimary sign-in succeeded but a second factor is required; errorMessage carries the challengeId.
mfaStepUpUnavailableMFA step-up was requested but the user has no factor configured for it.
unknownAn unclassified failure.

A finer-grained discriminator, most useful for OAuth-flow and biometric-gate failures.

OAuth flow:

ReasonMeaning
oauthUserCancelledThe user dismissed the system browser without completing sign-in.
oauthLockedA concurrent OAuth attempt is already in progress.
oauthStateMismatchThe state (CSRF) or iss (RFC 9700 §4.4 mix-up defense) check failed.
oauthRedirectMismatchThe callback redirect did not match what was configured.
oauthMissingParamsThe callback was missing code, state, or the one-time id.
oauthProviderErrorThe provider itself returned an error, or the system browser could not be launched.

Biometric gate:

ReasonMeaning
biometricCancelledThe user cancelled the biometric prompt.
biometricLockoutToo many failed attempts — may be transient or permanent (device-dependent).
biometricNotEnrolledNo biometric is enrolled on the device.
biometricUnavailableBiometric hardware is unavailable or disabled (for example, no device passcode set).

Session lifecycle:

ReasonMeaning
sessionExpiredThe session has expired.
sessionRevokedThe session was revoked.
refreshExpiredThe refresh token itself has expired (HTTP 401 on refresh).
refreshRevokedThe refresh token was revoked (HTTP 403 on refresh, or reuse detected).
refreshNetworkA network failure occurred specifically during a refresh attempt.
certPinMismatchThe server’s TLS certificate did not match a configured pin.

Generic:

ReasonMeaning
networkA generic network-level failure.
unknownUnclassified.

A small number of calls throw instead of returning an SdkError, because they represent a mistake in how the SDK is being used rather than a runtime condition an end user triggered:

  • RakomiProvider(apiBaseUrl: ..., jwksUrl: ...) — an invalid URL (not https:// and not the documented dev-loopback exception) throws ArgumentError at construction time. See Configuration.
  • performSocialSignIn(...) — an invalid or banned redirectUri scheme throws ArgumentError before any network call. See Authentication.
  • RakomiAuth.signInWithProvider(...) and RakomiAuth.verifyMfa(...) (the bare controller methods, as opposed to performSocialSignIn / verifyMfaImpl) throw UnsupportedError by design — they exist to point you at the correct entry point. See Authentication.

If you have opted a session into DPoP sender-constrained refresh, a bound refresh can additionally fail with a dpop_prover_unavailable or invalid_dpop_proof condition, surfaced through the same SdkError envelope (code: refreshFailed or networkError, with the DPoP-specific wire code carried on errorMessage for diagnostics). A DPoP proof failure never silently falls back to an unbound (Bearer) request.