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 AuthResourceSigns 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, InterruptedExceptionSigns 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 readInterruptedException: if the thread is interrupted while waiting for the responseOvokConfigException: if the client was built with a client secret
public LoginResult login(
LoginCredentials credentials,
RequestOptions options) throws IOException, InterruptedExceptionSigns 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 typeoptions: 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 readInterruptedException: if the thread is interrupted while waiting for the responseOvokConfigException: if the client was built with a client secret
verifyMfa
public LoginResult verifyMfa(
MfaChallenge challenge,
String code) throws IOException, InterruptedExceptionCompletes 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 fromlogincode: the one-time code
Returns: the signed-in result
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the responseOvokConfigException: if the client was built with a client secret
public LoginResult verifyMfa(
MfaChallenge challenge,
String code,
RequestOptions options) throws IOException, InterruptedExceptionCompletes 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 fromlogincode: the one-time codeoptions: 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 readInterruptedException: if the thread is interrupted while waiting for the responseOvokConfigException: if the client was built with a client secret
register
public RegisterResult register(Map<String, ?> details) throws IOException, InterruptedExceptionRegisters a patient and signs them in (POST /auth/tenant/Patient/register).
Parameters:
details:email,password,passwordConfirm, and optionallyname,surname,continueAsPatientToken
Returns: the session, or a clinician-invite result
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the responseOvokValidationException: if the password and its confirmation differOvokConfigException: if the client was built with a client secret
public RegisterResult register(
Map<String, ?> details,
RequestOptions options) throws IOException, InterruptedExceptionRegisters a patient and signs them in (POST /auth/tenant/Patient/register).
Parameters:
details:email,password,passwordConfirm, and optionallyname,surname,continueAsPatientTokenoptions: 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 readInterruptedException: if the thread is interrupted while waiting for the responseOvokValidationException: if the password and its confirmation differOvokConfigException: if the client was built with a client secret
registerPractitioner
public Session registerPractitioner(Map<String, ?> details) throws IOException, InterruptedExceptionRegisters a practitioner and signs them in (POST /auth/tenant/Practitioner/register).
Parameters:
details:email,password,passwordConfirm, and optionallyname,surname
Returns: the new session
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the responseOvokValidationException: if the password and its confirmation differOvokConfigException: if the client was built with a client secret
public Session registerPractitioner(
Map<String, ?> details,
RequestOptions options) throws IOException, InterruptedExceptionRegisters a practitioner and signs them in (POST /auth/tenant/Practitioner/register).
Parameters:
details:email,password,passwordConfirm, and optionallyname,surnameoptions: per-request options, such as the timeout
Returns: the new session
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the responseOvokValidationException: if the password and its confirmation differOvokConfigException: if the client was built with a client secret
socialLogin
public Session socialLogin(
String provider,
Map<String, ?> credential) throws IOException, InterruptedExceptionSigns a user in with an external identity provider (POST /auth/external/{provider}).
Parameters:
provider: the provider name, such asgooglecredential: the provider credential; aninternalIdentry is sent as a query parameter
Returns: the new session
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the responseOvokConfigException: if the config has no client ID or has a client secret
public Session socialLogin(
String provider,
Map<String, ?> credential,
RequestOptions options) throws IOException, InterruptedExceptionSigns a user in with an external identity provider (POST /auth/external/{provider}).
Parameters:
provider: the provider name, such asgooglecredential: the provider credential; aninternalIdentry is sent as a query parameteroptions: per-request options, such as the timeout
Returns: the new session
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the responseOvokConfigException: 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, InterruptedExceptionReads 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 readInterruptedException: if the thread is interrupted while waiting for the response
public JsonNode me(RequestOptions options) throws IOException, InterruptedExceptionReads 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 readInterruptedException: if the thread is interrupted while waiting for the response
changePassword
public JsonNode changePassword(Map<String, ?> request) throws IOException, InterruptedExceptionChanges the signed-in user's password (PATCH /v2/auth/change-password).
Parameters:
request:oldPasswordandnewPassword
Returns: the response body
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the responseOvokValidationException: if either password is missing
public JsonNode changePassword(
Map<String, ?> request,
RequestOptions options) throws IOException, InterruptedExceptionChanges the signed-in user's password (PATCH /v2/auth/change-password).
Parameters:
request:oldPasswordandnewPasswordoptions: per-request options, such as the timeout
Returns: the response body
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the responseOvokValidationException: if either password is missing
resetPassword
public JsonNode resetPassword(Map<String, ?> request) throws IOException, InterruptedExceptionRequests a password-reset email (POST /v2/auth/reset-password).
Parameters:
request: the reset request;clientIddefaults to the configured client ID
Returns: the response body
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the response
public JsonNode resetPassword(
Map<String, ?> request,
RequestOptions options) throws IOException, InterruptedExceptionRequests a password-reset email (POST /v2/auth/reset-password).
Parameters:
request: the reset request;clientIddefaults to the configured client IDoptions: per-request options, such as the timeout
Returns: the response body
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the response
completePasswordReset
public JsonNode completePasswordReset(
Map<String, ?> request) throws IOException, InterruptedExceptionSets 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 readInterruptedException: if the thread is interrupted while waiting for the response
public JsonNode completePasswordReset(
Map<String, ?> request,
RequestOptions options) throws IOException, InterruptedExceptionSets a new password from a reset link (POST /v2/auth/reset-password/process).
Parameters:
request: the reset token and new passwordoptions: per-request options, such as the timeout
Returns: the response body
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the response
deleteAccount
public JsonNode deleteAccount(Map<String, ?> request) throws IOException, InterruptedExceptionDeletes 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 readInterruptedException: if the thread is interrupted while waiting for the response
public JsonNode deleteAccount(
Map<String, ?> request,
RequestOptions options) throws IOException, InterruptedExceptionDeletes the signed-in user's account (DELETE /auth/delete).
Parameters:
request: the deletion requestoptions: per-request options, such as the timeout
Returns: the response body
Throws:
IOException: if the request cannot be sent or the response cannot be readInterruptedException: if the thread is interrupted while waiting for the response
logout
public void logout() throws IOException, InterruptedExceptionEnds 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 readInterruptedException: if the thread is interrupted while waiting for the responseOvokConfigException: if the client was built with a client secret
public void logout(RequestOptions options) throws IOException, InterruptedExceptionEnds 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 readInterruptedException: if the thread is interrupted while waiting for the responseOvokConfigException: if the client was built with a client secret
Last updated on