Advanced Configuration
The Web3Auth SDK provides extensive configuration options that allow you to customize authentication flows, UI appearance, blockchain integrations, and security features to meet your application's specific requirements.
Configuration Structure
When setting up Web3Auth, you'll pass in the options to the constructor. This consists of:
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork
var web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
)
)
// Handle user signing in when app is in background
web3Auth.setResultUrl(intent?.data)
Web3AuthOptions
The Web3Auth Constructor takes an object with Web3AuthOptions
as input.
- Basic Parameters
- Advanced Parameters
- Interface
Parameter | Description |
---|---|
context | Android context to launch Web-based authentication, usually is the current activity. It's a mandatory field, and accepts android.content.Context as a value. |
clientId | Your Web3Auth Client ID. You can get it from Web3Auth Dashboard under project details. It's a mandatory field of type String |
web3AuthNetwork | Defines the Web3Auth Network. It's a mandatory field of type Web3AuthNetwork . |
redirectUrl | URL that Web3Auth will redirect API responses upon successful authentication from browser. It's a mandatory field of type String . |
sessionTime? | It allows developers to configure the session management time. Session Time is in seconds, default is 86400 seconds which is 1 day. sessionTime can be max 30 days |
useSFAKey? | Use SFA Key to get single factor auth key. It's an optional field with default value as false . Useful for Wallet Pregeneration and SFA mode. |
chains? | Custom chain configuration for blockchain networks. It takes Chains as a value. |
Parameter | Description |
---|---|
whiteLabel? | WhiteLabel options for web3auth. It helps you define custom UI, branding, and translations for your brand app. It takes WhiteLabelData as a value. |
authConnectionConfig? | Auth connection config for the custom auth connections. It takes List<AuthConnectionConfig> as a value. |
mfaSettings? | Allows developers to configure the MFA settings for authentication. It takes MfaSettings as a value. |
walletServicesConfig? | Configuration for wallet services including whitelabel options. It takes WalletServicesConfig as a value. |
data class Web3AuthOptions(
var context: Context,
val clientId: String,
val web3AuthNetwork: Web3AuthNetwork,
var authBuildEnv: BuildEnv? = BuildEnv.PRODUCTION,
var redirectUrl: String,
var sdkUrl: String = getSdkUrl(authBuildEnv),
val whiteLabel: WhiteLabelData? = null,
val authConnectionConfig: List<AuthConnectionConfig>? = null,
val useSFAKey: Boolean? = false,
val chains: Chains? = null,
val mfaSettings: MfaSettings? = null,
val sessionTime: Int = 86400,
val walletServicesConfig: WalletServicesConfig? = null,
val defaultChainId: String? = null,
val enableLogging: Boolean? = false
)
Session Management
Control how long users stay authenticated and how sessions persist. The session key is stored in the device's encrypted Keystore.
Key Configuration Options:
sessionTime
- Session duration in seconds. Controls how long users remain authenticated before needing to log in again.- Minimum: 1 second (
1
). - Maximum: 30 days (
86400 * 30
). - Default: 7 days (
86400 * 7
).
- Minimum: 1 second (
var web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
sessionTime = 86400 * 7, // 7 days (in seconds)
redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
)
)
Custom Authentication Methods
Control the login options presented to your users. For detailed configuration options and implementation examples, see the Custom Authentication section.
UI Customization
Create a seamless brand experience by customizing the Web3Auth Login Screens to match your application's design. For complete customization options, refer to the Whitelabeling & UI Customization section.
Multi-Factor Authentication (MFA)
Add additional security layers to protect user accounts with two-factor authentication. For detailed configuration options and implementation examples, see the Multi-Factor Authentication section.
Key Configuration Options:
mfaSettings
- Configure MFA settings for different authentication flowsmfaLevel
- Control when users are prompted to set up MFA