Skip to main content

Authentication

Package: com.mimik.mimoe.auth

Authentication and token management.

AuthClient

class AuthClient

Authentication sub-client.

Provides developer token, federated, email, and phone authentication flows, as well as token management and refresh.

All auth methods follow the same pattern:

  1. Get an Edge ID token from the local runtime (via AccountClient)
  2. POST form-encoded data to the auth server ({authUrl}/token)
  3. Parse the token response and store securely

Access via client.auth.

Properties

NameSummary
autoRefreshEnabledvar autoRefreshEnabled: Boolean
Whether auto-refresh is enabled. Default: true.
currentTokensval currentTokens: AuthTokens?
Currently stored tokens, or null if not logged in.
tokenFlowval tokenFlow: Flow<AuthTokens?>
Flow of token updates. Emits null when logged out.

Functions

loginWithDeveloperToken

suspend fun loginWithDeveloperToken(clientId: String, developerToken: String): Result<AuthTokens>

Authenticate using a developer token from the mimik console.

loginWithEmail

suspend fun loginWithEmail(clientId: String, email: String, password: String): Result<AuthTokens>

Authenticate with email and password.

loginWithFederatedToken

suspend fun loginWithFederatedToken(clientId: String, federatedToken: String, provider: FederatedProvider): Result<AuthTokens>

Authenticate using a token from an external OAuth provider.

logout

fun logout()

Clear all stored tokens (logout).

refreshTokens

suspend fun refreshTokens(): Result<AuthTokens>

Refresh the current tokens using the stored refresh token.

requestEmailVerification

suspend fun requestEmailVerification(clientId: String, email: String): Result<EmailVerificationResult>

Request email verification code for account registration.

requestPasswordReset

suspend fun requestPasswordReset(clientId: String, email: String): Result<Unit>

Request password reset for an email account.

requestPhoneVerification

suspend fun requestPhoneVerification(clientId: String, phoneNumber: String): Result<PhoneVerificationResult>

Request phone verification SMS code.

resetPassword

suspend fun resetPassword(clientId: String, email: String, code: String, newPassword: String): Result<Unit>

Complete password reset with the verification code.

verifyEmail

suspend fun verifyEmail(clientId: String, email: String, code: String, mfaToken: String, password: String): Result<AuthTokens>

Verify email with the code received and complete registration.

verifyPhone

suspend fun verifyPhone(clientId: String, phoneNumber: String, code: String, mfaToken: String): Result<AuthTokens>

Verify phone with the SMS code to complete authentication.


AuthTokens

data class AuthTokens(
val accessToken: String,
val idToken: String?,
val refreshToken: String?,
val expiresAt: Instant,
val scopes: Set<String>
)

Represents the set of tokens obtained from authentication.

See also: AuthClient

Constructors

constructor(
accessToken: String,
idToken: String?,
refreshToken: String?,
expiresAt: Instant,
scopes: Set<String>
)

Properties

NameSummary
accessTokenval accessToken: String
OAuth 2.0 access token.
expiresAtval expiresAt: Instant
When the access token expires.
idTokenval idToken: String?
OpenID Connect ID token (may be null for some flows).
isExpiredval isExpired: Boolean
Whether the access token has expired.
refreshTokenval refreshToken: String?
OAuth 2.0 refresh token for obtaining new access tokens.
scopesval scopes: Set<String>
Granted OAuth scopes.

EmailVerificationResult

data class EmailVerificationResult(
val mfaToken: String,
val oobCode: String = ""
)

Result from email verification request.

Constructors

constructor(mfaToken: String, oobCode: String = "")

Properties

NameSummary
mfaTokenval mfaToken: String
MFA token for the second step.
oobCodeval oobCode: String
Out-of-band code (sent to user's email).

FederatedProvider

enum FederatedProvider : Enum<FederatedProvider>

Supported federated authentication providers.

See also: AuthClient.loginWithFederatedToken

Entries

NameDescription
GOOGLEGOOGLE
APPLEAPPLE
FACEBOOKFACEBOOK
CUSTOMCUSTOM

Properties

NameSummary
entriesval entries: EnumEntries<FederatedProvider>
Returns a representation of an immutable list of all enum entries, in the order they're declared.
nameval name: String
ordinalval ordinal: Int

Functions

valueOf

fun valueOf(value: String): FederatedProvider

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

values

fun values(): Array<FederatedProvider>

Returns an array containing the constants of this enum type, in the order they're declared.


PhoneVerificationResult

data class PhoneVerificationResult(
val mfaToken: String,
val oobCode: String = ""
)

Result from phone verification request.

Constructors

constructor(mfaToken: String, oobCode: String = "")

Properties

NameSummary
mfaTokenval mfaToken: String
MFA token for the second step.
oobCodeval oobCode: String
Out-of-band code (sent to user's phone).