Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.crossmint.com/llms.txt

Use this file to discover all available pages before exploring further.

Abstract Interface Class Authentication sub-client — email OTP, OAuth, wallet sign-in, and session lifecycle. Exposed on CrossmintClient.auth.
abstract interface class CrossmintAuthClient
Observable via state (immediate), stateListenable (Flutter ValueListenable), or states (Stream). Call restoreSession on app startup (once CrossmintClient.initialize has completed) so any persisted JWT can hydrate before the first frame.

Properties

state

CrossmintAuthState get state
The current auth state snapshot.

stateListenable

ValueListenable<CrossmintAuthState> get stateListenable
Reactive handle on state — suitable for ValueListenableBuilder.

states

Stream<CrossmintAuthState> get states
Stream of auth-state changes. Emits on every state mutation.

Methods

restoreSession

Future<void> restoreSession()
Reads any persisted session from CrossmintAuthStorage and applies it to the client. Safe to call once per app launch — prefer using the result of CrossmintClient.initialize which calls this internally.

loginWithOAuth

Future<void> loginWithOAuth(CrossmintOAuthProvider provider)
Opens the Crossmint-hosted OAuth flow for provider (Google, Twitter, etc.). The response comes back through CrossmintAuthCallbackRouter — make sure it is started before calling this.

sendEmailOtp

Future<CrossmintEmailOtpChallenge> sendEmailOtp(String email)
Requests the Crossmint API to send an email OTP to email. Returns a challenge that confirmEmailOtp completes.

confirmEmailOtp

Future<bool> confirmEmailOtp({
  required String email,
  required String emailId,
  required String token,
})
Submits an email OTP challenge — pass the emailId from the challenge and the token the user entered. Returns true on success.

completeOAuth

Future<bool> completeOAuth(Uri callbackUri)
Completes an OAuth flow from a deep-link callback URI. Normally invoked by CrossmintAuthCallbackRouter; call directly only for custom routing.

completeOAuthWithOneTimeSecret

Future<bool> completeOAuthWithOneTimeSecret(String oneTimeSecret)
Completes an OAuth flow from a one-time secret (SSR / server-mediated callbacks). Returns true on success.

signInWithWallet

Future<CrossmintWalletAuthChallenge> signInWithWallet(
  String address,
  String type,
)
Starts wallet-based authentication. Returns a challenge that the wallet must sign. type is 'evm' or 'solana'.

authenticateWallet

Future<bool> authenticateWallet(
  String address,
  String type,
  String signature,
)
Completes wallet-based authentication with the signed challenge.

getSession

Future<CrossmintAuthSession?> getSession()
Returns the current session (JWT + metadata), or null if not signed in. Does not hit the network — reads from in-memory state.

getUser

Future<CrossmintAuthenticatedUser?> getUser({bool forceRefresh = false})
Returns the authenticated user’s profile. Caches the result; pass forceRefresh: true to bypass the cache and refetch.

logout

Future<void> logout()
Signs the user out — clears persisted storage, cached session/user, and POSTs to the Crossmint (or custom) logout endpoint.

setJwt

Future<void> setJwt(String? jwt)
Sets a custom JWT for “Bring Your Own Auth” (BYOA) flows.