Auth resource

Generated reference for ovok_sdk: auth resource.

  • Stable unknown
  • Release candidate since 0.1.0-rc.4
  • Development since 0.1.0-dev.23+d339d81

AuthResource

class AuthResource

Sign-in, registration, passwords and the account; sign-in runs anonymously.

Reached through ovok.auth. Every request throws an OvokException subclass when it fails.

Constructors

AuthResource.new

AuthResource(
  HttpClient _http,
  String _tenantCode,
  UserSession _session,
  String? _clientId,
)

clientId is the ClientApplication social sign-in and password resets go through.

ParameterTypeKindDefault
_httpHttpClientpositional
_tenantCodeStringpositional
_sessionUserSessionpositional
_clientIdString?positional

Properties

AuthResource.sessions

final AuthSessionsResource sessions

The account's sessions on the server.

Methods

AuthResource.login

Future<LoginResult> login({
  required ProfileType profileType,
  required String email,
  required String password,
})

Runs the tenant login with PKCE for the configured tenant.

Calls POST auth/tenant/{profileType}/login/start, then the token step. Returns SignedIn, or MfaRequired when the account needs a second factor.

ParameterTypeKindDefault
profileTypeProfileTyperequired named
emailStringrequired named
passwordStringrequired named

Returns Future<LoginResult>.

AuthResource.verifyMfa

Future<LoginResult> verifyMfa(MfaChallenge challenge, String code)

Completes a login that returned MfaRequired with the user's MFA code.

Calls POST auth/tenant/{profileType}/login/mfa, then the token step.

ParameterTypeKindDefault
challengeMfaChallengepositional
codeStringpositional

Returns Future<LoginResult>.

AuthResource.register

Future<RegisterResult> register(Registration registration, {String? continueAsPatientToken})

Registers a patient account and signs it in.

Calls POST auth/tenant/Patient/register. Returns SignedIn, or ClinicianInvite when the project routes the email to a clinician invitation, which signs no one in. Throws OvokValidationException when the password and its confirmation differ.

ParameterTypeKindDefault
registrationRegistrationpositional
continueAsPatientTokenString?named

Returns Future<RegisterResult>.

AuthResource.registerPractitioner

Future<Session> registerPractitioner(Registration registration)

Registers a practitioner account and signs it in.

Calls POST auth/tenant/Practitioner/register. Throws OvokValidationException when the password and its confirmation differ.

ParameterTypeKindDefault
registrationRegistrationpositional

Returns Future<Session>.

AuthResource.socialLogin

Future<Session> socialLogin(
  SocialProvider provider, {
  required String internalId,
  required Map<String, dynamic> credential,
})

Signs in with an Apple or Google credential.

Calls POST auth/external/{provider}. credential is the provider's sign-in result, sent as it is. Throws OvokConfigException when the client was built without clientId.

ParameterTypeKindDefault
providerSocialProviderpositional
internalIdStringrequired named
credentialMap<String, dynamic>required named

Returns Future<Session>.

AuthResource.current

Future<Session?> current()

The stored session, or null when no one is signed in.

Returns Future<Session?>.

AuthResource.me

Future<Map<String, dynamic>> me()

Fetches the signed-in account. Calls GET auth/me.

Returns Future<Map<String, dynamic>>.

AuthResource.changePassword

Future<Map<String, dynamic>> changePassword({required String oldPassword, required String newPassword})

Changes the signed-in user's password. Calls PATCH v2/auth/change-password.

The confirmation is the app's to check; Ovok Core never receives it.

ParameterTypeKindDefault
oldPasswordStringrequired named
newPasswordStringrequired named

Returns Future<Map<String, dynamic>>.

AuthResource.resetPassword

Future<Map<String, dynamic>> resetPassword({
  required String email,
  required ProfileType type,
  String? clientId,
})

Starts a password reset for email. Calls POST v2/auth/reset-password.

clientId overrides the client's configured clientId.

ParameterTypeKindDefault
emailStringrequired named
typeProfileTyperequired named
clientIdString?named

Returns Future<Map<String, dynamic>>.

AuthResource.completePasswordReset

Future<Map<String, dynamic>> completePasswordReset({
  required String id,
  required String secret,
  required String password,
})

Sets password with the id and secret from the reset email.

Calls POST v2/auth/reset-password/process.

ParameterTypeKindDefault
idStringrequired named
secretStringrequired named
passwordStringrequired named

Returns Future<Map<String, dynamic>>.

AuthResource.deleteAccount

Future<Map<String, dynamic>> deleteAccount({required int days, bool wipe = false})

Schedules the deletion in days; wipe also deletes the medical data then.

Calls DELETE auth/delete.

ParameterTypeKindDefault
daysintrequired named
wipeboolnamedfalse

Returns Future<Map<String, dynamic>>.

AuthResource.logout

Future<void> logout()

Ends the session on the server, and always locally, even when the server cannot be reached.

Calls DELETE auth/session/current.

Returns Future<void>.

SocialProvider

enum SocialProvider

An identity provider for AuthResource.socialLogin.

Values

SocialProvider.apple

static const SocialProvider apple

Sign in with Apple.

SocialProvider.google

static const SocialProvider google

Sign in with Google.

Last updated on

On this page