Skip to main content
The Kotlin SDK supports email OTP and Google sign-in through OIDC ID-token authentication or authorization-code redirect authentication. Authentication returns an active wallet by default. Use manual wallet selection when your app should present wallet choices.

Start Email Auth

Send a one-time code to the user’s email address.
client.wallet.startEmailAuth("user@example.com")
Parameters
ParameterTypeDescription
emailStringEmail address that receives the one-time code.
Returns Returns Unit.

Complete Email Auth

Complete the flow with the code entered by the user. Automatic mode returns an active wallet when possible.
import com.omsclient.kotlin_sdk.wallet.CompleteAuthResult

val result = client.wallet.completeEmailAuth("123456")
check(result is CompleteAuthResult.WalletSelected)

println("Wallet address: ${result.walletAddress}")
println("Wallet ID: ${result.wallet.id}")
Use manual wallet selection when the app needs to choose between wallets before activating one.
import com.omsclient.kotlin_sdk.wallet.CompleteAuthResult
import com.omsclient.kotlin_sdk.wallet.WalletSelectionBehavior

val selectionResult = client.wallet.completeEmailAuth(
    code = "123456",
    walletSelection = WalletSelectionBehavior.Manual,
)
check(selectionResult is CompleteAuthResult.WalletSelection)

selectionResult.pendingSelection.createAndSelectWallet(reference = "main")
Parameters
ParameterTypeDescription
codeStringOne-time code entered by the user.
walletSelectionWalletSelectionBehaviorDefaults to WalletSelectionBehavior.Automatic.
walletTypeWalletTypeOptional wallet type. Defaults to WalletType.Ethereum.
sessionLifetimeSecondsLongOptional requested wallet API session lifetime in seconds. Defaults to one week.
Returns Returns CompleteAuthResult, either WalletSelected or WalletSelection.

Sign In With OIDC ID Token

Use OIDC ID-token auth for providers such as Google Sign-In with Android Credential Manager.
import com.omsclient.kotlin_sdk.wallet.CompleteAuthResult

val result = client.wallet.signInWithOidcIdToken(
    idToken = googleIdToken,
    issuer = "https://accounts.google.com",
    audience = "YOUR_WEB_CLIENT_ID",
)
check(result is CompleteAuthResult.WalletSelected)

println("Wallet address: ${result.walletAddress}")
Parameters
ParameterTypeDescription
idTokenStringOIDC ID token from the identity provider.
issuerStringExpected token issuer, such as https://accounts.google.com.
audienceStringExpected token audience.
walletSelectionWalletSelectionBehaviorDefaults to WalletSelectionBehavior.Automatic.
walletTypeWalletTypeOptional wallet type. Defaults to WalletType.Ethereum.
sessionLifetimeSecondsLongOptional requested wallet API session lifetime in seconds. Defaults to one week.
Returns Returns CompleteAuthResult.

Start OIDC Redirect Auth

Start a Google authorization-code PKCE flow and open the returned authorization URL in app-owned UI such as Custom Tabs.
import com.omsclient.kotlin_sdk.wallet.OidcProviders

val redirect = client.wallet.startOidcRedirectAuth(
    provider = OidcProviders.google(),
    redirectUri = "yourapp://auth/callback",
)

openCustomTab(redirect.authorizationUrl)
Register an Android intent filter for the callback scheme, such as yourapp, before using redirect auth. Parameters
ParameterTypeDescription
providerOidcProviderConfigGoogle provider configuration returned by OidcProviders.google().
redirectUriStringApp callback URL that receives the provider redirect. Configure this URL scheme or app link with an Android intent filter.
walletTypeWalletTypeOptional wallet type. Defaults to WalletType.Ethereum.
authorizeParamsMap<String, String>Extra authorization query parameters passed to the provider.
loginHintString?Optional Google login_hint. When omitted for Google, the SDK can reuse the previous session email. Pass an empty string to force no hint.
Returns Returns StartOidcRedirectAuthResult with the provider authorizationUrl. state and challenge are SDK-managed values.

Handle OIDC Redirect Callback

Pass incoming app-link URLs to the callback handler. It is safe to call from onCreate or onNewIntent for unrelated links.
import com.omsclient.kotlin_sdk.wallet.OidcRedirectAuthResult

when (val result = client.wallet.handleOidcRedirectCallback(intent.data?.toString())) {
    is OidcRedirectAuthResult.Completed -> {
        println("Wallet address: ${result.wallet.address}")
    }
    is OidcRedirectAuthResult.WalletSelection -> {
        result.pendingSelection.createAndSelectWallet()
    }
    OidcRedirectAuthResult.NotOidcRedirectCallback -> Unit
    OidcRedirectAuthResult.NoPendingAuth -> Unit
    is OidcRedirectAuthResult.Failed -> throw result.error
}
Parameters
ParameterTypeDescription
callbackUrlString?Incoming app-link URL.
walletSelectionWalletSelectionBehaviorDefaults to WalletSelectionBehavior.Automatic.
sessionLifetimeSecondsLongOptional requested wallet API session lifetime in seconds. Defaults to one week.
Returns Returns OidcRedirectAuthResult.

Use Wallet

Activate an existing wallet by server-side wallet ID.
client.wallet.useWallet(walletId = "wallet-id")
Parameters
ParameterTypeDescription
walletIdStringWallet ID returned by auth completion or listWallets().
Returns Returns WalletSelectionResult.

Create Wallet

Create and activate a new wallet for the authenticated user.
val result = client.wallet.createWallet(reference = "main")

println("New wallet: ${result.walletAddress}")
Parameters
ParameterTypeDescription
walletTypeWalletTypeWallet type to create. Defaults to WalletType.Ethereum.
referenceString?Optional app-defined wallet reference.
Returns Returns WalletSelectionResult.