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 Unity application's specific requirements.
Configuration Structure
When setting up Web3Auth, you'll pass in the options to the constructor. This consists of:
web3Auth = GetComponent<Web3Auth>();
web3Auth.setOptions(new Web3AuthOptions(){
clientId = "YOUR_CLIENT_ID", // Get your Client ID from Web3Auth Dashboard
network = Web3Auth.Network.SAPPHIRE_MAINNET, // or Web3Auth.Network.SAPPHIRE_DEVNET
redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity/auth"),
});
Web3AuthOptions
The Web3Auth Constructor takes an object with Web3AuthOptions
as input.
- Table
- Class
Parameter | Description |
---|---|
clientId | Your Web3Auth Client ID from the Dashboard. It's a mandatory field of type string . |
network | Web3Auth Network: SAPPHIRE_MAINNET , SAPPHIRE_DEVNET , MAINNET , CYAN , AQUA or TESTNET . Mandatory field of type Web3Auth.Network . |
redirectUrl | URL that Web3Auth will redirect API responses upon successful authentication. It's a mandatory field of type Uri . |
whiteLabel? | WhiteLabel options for custom UI, branding, and translations. Takes WhiteLabelData as a value. |
loginConfig? | Login config for custom verifiers. Takes LoginConfigItem as a value. |
mfaSettings? | Configure MFA settings for authentication. Takes MfaSettings as a value. |
sessionTime? | Configure session management time in seconds. Default is 86400 seconds (1 day). Max 30 days. |
public class Web3AuthOptions
{
public string clientId { get; set; }
public Web3Auth.Network network { get; set; }
public Uri redirectUrl { get; set; }
public WhiteLabelData whiteLabel { get; set; }
public LoginConfigItem loginConfig { get; set; }
public MfaSettings mfaSettings { get; set; }
public int sessionTime { get; set; } = 86400;
}
Session Management
Control how long users stay authenticated and how sessions persist in Unity.
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: 1 day (
86400
).
- Minimum: 1 second (
web3Auth.setOptions(new Web3AuthOptions(){
clientId = "YOUR_CLIENT_ID",
network = Web3Auth.Network.SAPPHIRE_MAINNET,
sessionTime = 86400 * 7, // 7 days (in seconds)
redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity/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 Unity 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
DApp Share
Share authentication sessions across different applications. For detailed configuration options and implementation examples, see the DApp Share section.