Object StytchClient
-
- All Implemented Interfaces:
public class StytchClientThe StytchClient object is your entrypoint to the Stytch Consumer SDK and is how you interact with all of our supported authentication products.
-
-
Field Summary
Fields Modifier and Type Field Description private final static StateFlow<Boolean>isInitializedprivate final static MagicLinksmagicLinksprivate final static OTPotpsprivate final static Passwordspasswordsprivate final static Sessionssessionsprivate final static Biometricsbiometricsprivate final static UserManagementuserprivate final static OAuthoauthprivate final static Passkeyspasskeysprivate final static DFPdfpprivate final static CryptoWalletcryptoprivate final static TOTPtotpprivate final static ConsumerAuthMethodlastAuthMethodUsedpublic final static StytchClientINSTANCE
-
Method Summary
Modifier and Type Method Description final static Unitconfigure(Context context)This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. final static Unitconfigure(Context context, StytchClientOptions options, Function1<Boolean, Unit> callback)This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. final static Unitconfigure(Context context, Function1<Boolean, Unit> callback)This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. final static Unitconfigure(Context context, StytchClientOptions options)This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. final static Unitconfigure(Context context, String publicToken, Function1<Boolean, Unit> callback)This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. final static Unitconfigure(Context context, String publicToken, StytchClientOptions options)This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. final static Unitconfigure(Context context, String publicToken)This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. final static Unitconfigure(Context context, String publicToken, StytchClientOptions options, Function1<Boolean, Unit> callback)This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. final static DeeplinkHandledStatushandle(Uri uri, Integer sessionDurationMinutes)Call this method to parse out and authenticate deeplinks that your application receives. final static Unithandle(Uri uri, Integer sessionDurationMinutes, Function1<DeeplinkHandledStatus, Unit> callback)Call this method to parse out and authenticate deeplinks that your application receives. final static BooleancanHandle(Uri uri)A helper function for determining whether the deeplink is intended for Stytch. final static PKCECodePairgetPKCECodePair()Retrieve the most recently created PKCE code pair from the device, if available final static DeeplinkTokenPairparseDeeplink(Uri uri)Retrieve the token and a concrete token type from a deeplink final static StateFlow<Boolean>isInitialized()Exposes a flow that reports the initialization state of the SDK. final static MagicLinksgetMagicLinks()Exposes an instance of the MagicLinks interface whicih provides methods for sending and authenticating users with Email Magic Links. final static OTPgetOtps()Exposes an instance of the OTP interface which provides methods for sending and authenticating One-Time Passcodes (OTP) via SMS, WhatsApp, and Email. final static PasswordsgetPasswords()Exposes an instance of the Passwords interface which provides methods for authenticating, creating, resetting, and performing strength checks of passwords. final static SessionsgetSessions()Exposes an instance of the Sessions interface which provides methods for authenticating, updating, or revoking sessions, and properties to retrieve the existing session token (opaque or JWT). final static BiometricsgetBiometrics()Exposes an instance of the Biometrics interface which provides methods for detecting biometric availability, registering, authenticating, and removing biometrics identifiers. final static UserManagementgetUser()Exposes an instance of the UserManagement interface which provides methods for retrieving an authenticated user and deleting authentication factors from an authenticated user. final static OAuthgetOauth()Exposes an instance of the OAuth interface which provides methods for authenticating a user via a native Google OneTap prompt or any of our supported third-party OAuth providers final static PasskeysgetPasskeys()Exposes an instance of the Passkeys interface which provides methods for registering and authenticating with Passkeys. final static DFPgetDfp()Exposes an instance of the DFP interface which provides a method for retrieving a dfp_telemetry_id for use in DFP lookups on your backend server final static CryptoWalletgetCrypto()Exposes an instance of the CryptoWallet interface which provides methods for authenticating with a crypto wallet final static TOTPgetTotp()Exposes an instance of the TOTP interface which provides methods for creating, authenticating, and recovering TOTP codes final static ConsumerAuthMethodgetLastAuthMethodUsed()-
-
Method Detail
-
configure
final static Unit configure(Context context)
This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. You must call this method before making any Stytch authentication requests.
- Parameters:
context- The applicationContext of your app
-
configure
final static Unit configure(Context context, StytchClientOptions options, Function1<Boolean, Unit> callback)
This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. You must call this method before making any Stytch authentication requests.
- Parameters:
context- The applicationContext of your appoptions- Optional options to configure the StytchClientcallback- An optional callback that is triggered after configuration and initialization has completed
-
configure
final static Unit configure(Context context, Function1<Boolean, Unit> callback)
This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. You must call this method before making any Stytch authentication requests.
- Parameters:
context- The applicationContext of your appcallback- An optional callback that is triggered after configuration and initialization has completed
-
configure
final static Unit configure(Context context, StytchClientOptions options)
This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. You must call this method before making any Stytch authentication requests.
- Parameters:
context- The applicationContext of your appoptions- Optional options to configure the StytchClient
-
configure
final static Unit configure(Context context, String publicToken, Function1<Boolean, Unit> callback)
This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. You must call this method before making any Stytch authentication requests.
- Parameters:
context- The applicationContext of your apppublicToken- Available via the Stytch dashboard in the API keys sectioncallback- An optional callback that is triggered after configuration and initialization has completed
-
configure
final static Unit configure(Context context, String publicToken, StytchClientOptions options)
This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. You must call this method before making any Stytch authentication requests.
- Parameters:
context- The applicationContext of your apppublicToken- Available via the Stytch dashboard in the API keys sectionoptions- Optional options to configure the StytchClient
-
configure
final static Unit configure(Context context, String publicToken)
This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. You must call this method before making any Stytch authentication requests.
- Parameters:
context- The applicationContext of your apppublicToken- Available via the Stytch dashboard in the API keys section
-
configure
final static Unit configure(Context context, String publicToken, StytchClientOptions options, Function1<Boolean, Unit> callback)
This configures the API for authenticating requests and the encrypted storage helper for persisting session data across app launches. You must call this method before making any Stytch authentication requests.
- Parameters:
context- The applicationContext of your apppublicToken- Available via the Stytch dashboard in the API keys sectionoptions- Optional options to configure the StytchClientcallback- An optional callback that is triggered after configuration and initialization has completed
-
handle
final static DeeplinkHandledStatus handle(Uri uri, Integer sessionDurationMinutes)
Call this method to parse out and authenticate deeplinks that your application receives. The currently supported deeplink types are: Email Magic Links, Third-Party OAuth, and Password resets.
For Email Magic Links and Third-Party OAuth deeplinks, it will return a DeeplinkHandledStatus.Handled class containing either the authenticated response or error.
For Password Reset deeplinks, it will return a DeeplinkHandledStatus.ManualHandlingRequired class containing the relevant token, so that you can provide an appropriate UI to the user for resetting their password. The returned token is used for making the subsequent StytchClient.passwords.resetByEmail() call.
Any other link types passed to this method will return a DeeplinkHandledStatus.NotHandled class.
- Parameters:
uri- intent.sessionDurationMinutes- desired session duration in minutes- Returns:
-
handle
final static Unit handle(Uri uri, Integer sessionDurationMinutes, Function1<DeeplinkHandledStatus, Unit> callback)
Call this method to parse out and authenticate deeplinks that your application receives. The currently supported deeplink types are: Email Magic Links, Third-Party OAuth, and Password resets.
For Email Magic Links and Third-Party OAuth deeplinks, it will return a DeeplinkHandledStatus.Handled class containing either the authenticated response or error.
For Password Reset deeplinks, it will return a DeeplinkHandledStatus.ManualHandlingRequired class containing the relevant token, so that you can provide an appropriate UI to the user for resetting their password. The returned token is used for making the subsequent StytchClient.passwords.resetByEmail() call.
Any other link types passed to this method will return a DeeplinkHandledStatus.NotHandled class.
- Parameters:
uri- intent.sessionDurationMinutes- desired session duration in minutescallback- A callback that receives a DeeplinkHandledStatus
-
canHandle
final static Boolean canHandle(Uri uri)
A helper function for determining whether the deeplink is intended for Stytch. Useful in contexts where your application makes use of a deeplink coordinator/manager which requires a synchronous determination of whether a given handler can handle a given URL.
- Parameters:
uri- intent.- Returns:
Boolean
-
getPKCECodePair
final static PKCECodePair getPKCECodePair()
Retrieve the most recently created PKCE code pair from the device, if available
-
parseDeeplink
final static DeeplinkTokenPair parseDeeplink(Uri uri)
Retrieve the token and a concrete token type from a deeplink
-
isInitialized
final static StateFlow<Boolean> isInitialized()
Exposes a flow that reports the initialization state of the SDK. You can use this, or the optional callback in the
configure()method, to know when the Stytch SDK has been fully initialized and is ready for use
-
getMagicLinks
final static MagicLinks getMagicLinks()
Exposes an instance of the MagicLinks interface whicih provides methods for sending and authenticating users with Email Magic Links.
-
getOtps
final static OTP getOtps()
Exposes an instance of the OTP interface which provides methods for sending and authenticating One-Time Passcodes (OTP) via SMS, WhatsApp, and Email.
-
getPasswords
final static Passwords getPasswords()
Exposes an instance of the Passwords interface which provides methods for authenticating, creating, resetting, and performing strength checks of passwords.
-
getSessions
final static Sessions getSessions()
Exposes an instance of the Sessions interface which provides methods for authenticating, updating, or revoking sessions, and properties to retrieve the existing session token (opaque or JWT).
-
getBiometrics
final static Biometrics getBiometrics()
Exposes an instance of the Biometrics interface which provides methods for detecting biometric availability, registering, authenticating, and removing biometrics identifiers.
-
getUser
final static UserManagement getUser()
Exposes an instance of the UserManagement interface which provides methods for retrieving an authenticated user and deleting authentication factors from an authenticated user.
-
getOauth
final static OAuth getOauth()
Exposes an instance of the OAuth interface which provides methods for authenticating a user via a native Google OneTap prompt or any of our supported third-party OAuth providers
-
getPasskeys
final static Passkeys getPasskeys()
Exposes an instance of the Passkeys interface which provides methods for registering and authenticating with Passkeys.
-
getDfp
final static DFP getDfp()
Exposes an instance of the DFP interface which provides a method for retrieving a dfp_telemetry_id for use in DFP lookups on your backend server
-
getCrypto
final static CryptoWallet getCrypto()
Exposes an instance of the CryptoWallet interface which provides methods for authenticating with a crypto wallet
-
getTotp
final static TOTP getTotp()
Exposes an instance of the TOTP interface which provides methods for creating, authenticating, and recovering TOTP codes
-
getLastAuthMethodUsed
final static ConsumerAuthMethod getLastAuthMethodUsed()
-
-
-
-