AuthResource

Signs users in and out and manages their account.

  • Stable unknown
  • Release candidate since 0.1.0-rc.4
  • Development since 0.1.0-dev.24+fa54770
public final class AuthResource

Signs users in and out and manages their account. Get it from Ovok.auth(). User sign-in needs a client built without a client secret.

Methods

sessions

public AuthSessionsResource sessions()

Returns the signed-in user's sessions.

Returns: the sessions resource

login

public LoginResult login(LoginCredentials credentials) throws IOException, InterruptedException

Signs a user in with email and password. Starts a PKCE sign-in (POST /auth/tenant/{profileType}/login/start) and, unless MFA is required, exchanges the code for tokens (POST /auth/tenant/{profileType}/login/token) and stores the session.

Parameters:

  • credentials: the email, password and profile type

Returns: the session, or the MFA challenge to answer with verifyMfa

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokConfigException: if the client was built with a client secret
public LoginResult login(
        LoginCredentials credentials,
        RequestOptions options) throws IOException, InterruptedException

Signs a user in with email and password. Starts a PKCE sign-in (POST /auth/tenant/{profileType}/login/start) and, unless MFA is required, exchanges the code for tokens (POST /auth/tenant/{profileType}/login/token) and stores the session.

Parameters:

  • credentials: the email, password and profile type
  • options: per-request options, such as the timeout

Returns: the session, or the MFA challenge to answer with verifyMfa

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokConfigException: if the client was built with a client secret

verifyMfa

public LoginResult verifyMfa(
        MfaChallenge challenge,
        String code) throws IOException, InterruptedException

Completes a sign-in that needs MFA. Verifies the code (POST /auth/tenant/{profileType}/login/mfa), exchanges it for tokens and stores the session.

Parameters:

  • challenge: the challenge from login
  • code: the one-time code

Returns: the signed-in result

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokConfigException: if the client was built with a client secret
public LoginResult verifyMfa(
        MfaChallenge challenge,
        String code,
        RequestOptions options) throws IOException, InterruptedException

Completes a sign-in that needs MFA. Verifies the code (POST /auth/tenant/{profileType}/login/mfa), exchanges it for tokens and stores the session.

Parameters:

  • challenge: the challenge from login
  • code: the one-time code
  • options: per-request options, such as the timeout

Returns: the signed-in result

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokConfigException: if the client was built with a client secret

register

public RegisterResult register(Map<String, ?> details) throws IOException, InterruptedException

Registers a patient and signs them in (POST /auth/tenant/Patient/register).

Parameters:

  • details: email, password, passwordConfirm, and optionally name, surname, continueAsPatientToken

Returns: the session, or a clinician-invite result

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokValidationException: if the password and its confirmation differ
  • OvokConfigException: if the client was built with a client secret
public RegisterResult register(
        Map<String, ?> details,
        RequestOptions options) throws IOException, InterruptedException

Registers a patient and signs them in (POST /auth/tenant/Patient/register).

Parameters:

  • details: email, password, passwordConfirm, and optionally name, surname, continueAsPatientToken
  • options: per-request options, such as the timeout

Returns: the session, or a clinician-invite result

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokValidationException: if the password and its confirmation differ
  • OvokConfigException: if the client was built with a client secret

registerPractitioner

public Session registerPractitioner(Map<String, ?> details) throws IOException, InterruptedException

Registers a practitioner and signs them in (POST /auth/tenant/Practitioner/register).

Parameters:

  • details: email, password, passwordConfirm, and optionally name, surname

Returns: the new session

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokValidationException: if the password and its confirmation differ
  • OvokConfigException: if the client was built with a client secret
public Session registerPractitioner(
        Map<String, ?> details,
        RequestOptions options) throws IOException, InterruptedException

Registers a practitioner and signs them in (POST /auth/tenant/Practitioner/register).

Parameters:

  • details: email, password, passwordConfirm, and optionally name, surname
  • options: per-request options, such as the timeout

Returns: the new session

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokValidationException: if the password and its confirmation differ
  • OvokConfigException: if the client was built with a client secret

socialLogin

public Session socialLogin(
        String provider,
        Map<String, ?> credential) throws IOException, InterruptedException

Signs a user in with an external identity provider (POST /auth/external/{provider}).

Parameters:

  • provider: the provider name, such as google
  • credential: the provider credential; an internalId entry is sent as a query parameter

Returns: the new session

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokConfigException: if the config has no client ID or has a client secret
public Session socialLogin(
        String provider,
        Map<String, ?> credential,
        RequestOptions options) throws IOException, InterruptedException

Signs a user in with an external identity provider (POST /auth/external/{provider}).

Parameters:

  • provider: the provider name, such as google
  • credential: the provider credential; an internalId entry is sent as a query parameter
  • options: per-request options, such as the timeout

Returns: the new session

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokConfigException: if the config has no client ID or has a client secret

current

public Session current()

Returns the stored user session without a network call.

Returns: the current session, or null when signed out or using client credentials

me

public JsonNode me() throws IOException, InterruptedException

Reads the signed-in user's profile and project (GET /auth/me).

Returns: the response body

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
public JsonNode me(RequestOptions options) throws IOException, InterruptedException

Reads the signed-in user's profile and project (GET /auth/me).

Parameters:

  • options: per-request options, such as the timeout

Returns: the response body

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

changePassword

public JsonNode changePassword(Map<String, ?> request) throws IOException, InterruptedException

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

Parameters:

  • request: oldPassword and newPassword

Returns: the response body

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokValidationException: if either password is missing
public JsonNode changePassword(
        Map<String, ?> request,
        RequestOptions options) throws IOException, InterruptedException

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

Parameters:

  • request: oldPassword and newPassword
  • options: per-request options, such as the timeout

Returns: the response body

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokValidationException: if either password is missing

resetPassword

public JsonNode resetPassword(Map<String, ?> request) throws IOException, InterruptedException

Requests a password-reset email (POST /v2/auth/reset-password).

Parameters:

  • request: the reset request; clientId defaults to the configured client ID

Returns: the response body

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
public JsonNode resetPassword(
        Map<String, ?> request,
        RequestOptions options) throws IOException, InterruptedException

Requests a password-reset email (POST /v2/auth/reset-password).

Parameters:

  • request: the reset request; clientId defaults to the configured client ID
  • options: per-request options, such as the timeout

Returns: the response body

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

completePasswordReset

public JsonNode completePasswordReset(
        Map<String, ?> request) throws IOException, InterruptedException

Sets a new password from a reset link (POST /v2/auth/reset-password/process).

Parameters:

  • request: the reset token and new password

Returns: the response body

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
public JsonNode completePasswordReset(
        Map<String, ?> request,
        RequestOptions options) throws IOException, InterruptedException

Sets a new password from a reset link (POST /v2/auth/reset-password/process).

Parameters:

  • request: the reset token and new password
  • options: per-request options, such as the timeout

Returns: the response body

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

deleteAccount

public JsonNode deleteAccount(Map<String, ?> request) throws IOException, InterruptedException

Deletes the signed-in user's account (DELETE /auth/delete).

Parameters:

  • request: the deletion request

Returns: the response body

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
public JsonNode deleteAccount(
        Map<String, ?> request,
        RequestOptions options) throws IOException, InterruptedException

Deletes the signed-in user's account (DELETE /auth/delete).

Parameters:

  • request: the deletion request
  • options: per-request options, such as the timeout

Returns: the response body

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response

logout

public void logout() throws IOException, InterruptedException

Ends the current session (DELETE /auth/session/current) and clears it locally, even if the call fails.

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokConfigException: if the client was built with a client secret
public void logout(RequestOptions options) throws IOException, InterruptedException

Ends the current session (DELETE /auth/session/current) and clears it locally, even if the call fails.

Parameters:

  • options: per-request options, such as the timeout

Throws:

  • IOException: if the request cannot be sent or the response cannot be read
  • InterruptedException: if the thread is interrupted while waiting for the response
  • OvokConfigException: if the client was built with a client secret

Last updated on

On this page