Object StytchClient

  • All Implemented Interfaces:

    
    public class StytchClient
    
                        

    The StytchClient object is your entrypoint to the Stytch Consumer SDK and is how you interact with all of our supported authentication products.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      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.
      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.
      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.
      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.
      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.
      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.
      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.
      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.
      final static DeeplinkHandledStatus handle(Uri uri, Integer sessionDurationMinutes) Call this method to parse out and authenticate deeplinks that your application receives.
      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.
      final static Boolean canHandle(Uri uri) A helper function for determining whether the deeplink is intended for Stytch.
      final static PKCECodePair getPKCECodePair() Retrieve the most recently created PKCE code pair from the device, if available
      final static DeeplinkTokenPair parseDeeplink(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 MagicLinks getMagicLinks() Exposes an instance of the MagicLinks interface whicih provides methods for sending and authenticating users with Email Magic Links.
      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.
      final static Passwords getPasswords() Exposes an instance of the Passwords interface which provides methods for authenticating, creating, resetting, and performing strength checks of passwords.
      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).
      final static Biometrics getBiometrics() Exposes an instance of the Biometrics interface which provides methods for detecting biometric availability, registering, authenticating, and removing biometrics identifiers.
      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.
      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
      final static Passkeys getPasskeys() Exposes an instance of the Passkeys interface which provides methods for registering and authenticating with Passkeys.
      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
      final static CryptoWallet getCrypto() Exposes an instance of the CryptoWallet interface which provides methods for authenticating with a crypto wallet
      final static TOTP getTotp() Exposes an instance of the TOTP interface which provides methods for creating, authenticating, and recovering TOTP codes
      final static ConsumerAuthMethod getLastAuthMethodUsed()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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 app
        options - Optional options to configure the StytchClient
        callback - 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 app
        callback - 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 app
        options - 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 app
        publicToken - Available via the Stytch dashboard in the API keys section
        callback - 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 app
        publicToken - Available via the Stytch dashboard in the API keys section
        options - 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 app
        publicToken - 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 app
        publicToken - Available via the Stytch dashboard in the API keys section
        options - Optional options to configure the StytchClient
        callback - 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:

        DeeplinkHandledStatus

      • 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 minutes
        callback - 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

      • 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

      • getTotp

         final static TOTP getTotp()

        Exposes an instance of the TOTP interface which provides methods for creating, authenticating, and recovering TOTP codes