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:
- Get an Edge ID token from the local runtime (via AccountClient)
- POST form-encoded data to the auth server (
{authUrl}/token) - Parse the token response and store securely
Access via client.auth.
Properties
| Name | Summary |
|---|---|
autoRefreshEnabled | var autoRefreshEnabled: BooleanWhether auto-refresh is enabled. Default: true. |
currentTokens | val currentTokens: AuthTokens?Currently stored tokens, or null if not logged in. |
tokenFlow | val 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
| Name | Summary |
|---|---|
accessToken | val accessToken: StringOAuth 2.0 access token. |
expiresAt | val expiresAt: InstantWhen the access token expires. |
idToken | val idToken: String?OpenID Connect ID token (may be null for some flows). |
isExpired | val isExpired: BooleanWhether the access token has expired. |
refreshToken | val refreshToken: String?OAuth 2.0 refresh token for obtaining new access tokens. |
scopes | val 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
| Name | Summary |
|---|---|
mfaToken | val mfaToken: StringMFA token for the second step. |
oobCode | val oobCode: StringOut-of-band code (sent to user's email). |
FederatedProvider
enum FederatedProvider : Enum<FederatedProvider>
Supported federated authentication providers.
See also: AuthClient.loginWithFederatedToken
Entries
| Name | Description |
|---|---|
GOOGLE | GOOGLE |
APPLE | APPLE |
FACEBOOK | FACEBOOK |
CUSTOM | CUSTOM |
Properties
| Name | Summary |
|---|---|
entries | val entries: EnumEntries<FederatedProvider>Returns a representation of an immutable list of all enum entries, in the order they're declared. |
name | val name: String |
ordinal | val 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
| Name | Summary |
|---|---|
mfaToken | val mfaToken: StringMFA token for the second step. |
oobCode | val oobCode: StringOut-of-band code (sent to user's phone). |