KratosClient
The KratosClient provides an API client for interacting with an Ory Kratos server.
Usage
To create a client
final client = KratosClient(
baseUri: Uri.parse('https://kratos.example.com'),
browserCallback: (url) async {
// open browser and return code
},
);
Features
The main available APIs are
Registration
registerWithPassword- Register using email and passwordregisterWithOidc- Register using OpenID Connect providerregisterWithPasskey- Register using a passkey
Login
loginWithPassword- Login with email and passwordloginWithPasskey- Login with a passkey
Verification
getVerificationFlow- Get verification flowverifyAccount- Complete email verification
Recovery
getRecoveryFlow- Get account recovery flowsendEmailRecoveryFlow- Initiate email account recoverysendCodeRecoveryFlow- Submit recovery code
Profile
getUserProfile- Get user profileupdateTraits- Update user profile traitsupdatePassword- Update user password
Settings
addPasskey- Add a new passkeyremovePasskey- Remove a linked passkeygetPasskeys- Get all linked passkeys
Other
logout- Logout userrefreshSessionToken- Refresh session tokenisSessionValid- Check if session is validgetSession- Get session
Credentials Storage
The client handles persisting credentials like the session token. By default it uses FlutterSecureCredentialsStorage but you can pass a custom CredentialsStorage on construction.
Error Handling
Most methods return a union type for success or failure responses. See code for details on specific error types.
HTTP Client
The http.Client used to make requests can be customized by passing your own on construction.
Logging
Debug logging is printed using the logging package.
Browser vs Api flows
In Browser flows session is stored in http-only cookie and CredentialsStorage is not used.
In Api flows token is stored in CredentialsStorage.