Skip to main content

Using Single Factor Auth Flutter SDK

After successfully installing and initializing SingleFactorAuth, you can use it to authenticate your users and obtain their private and public keys.

Note

Web3Auth SFA Flutter SDK only works for users who have not enabled MFA. For MFA enabled users, you'll see an Error message.

The SingleFactorAuth instance natively provides the following methods:

  • connect - Use to login user and retrive private key pair.
  • initialize - This method helps to achieve session management. It authenticates user if the session is present, avoiding re-logging.

Login User

To obtain a user's private key using the Web3Auth SFA Flutter SDK, you can call the connect method. The method accepts LoginParams, and returns SFAKey.

Parameters

ParameterDescription
verifierThe verifier obtained from the Web3Auth Dashboard. It's a mandatory field and takes String as a value.
verifierIdThe verifierId used for the verification. It takes String as a value.
idTokenThe idToken of the user obtained from login provider. It takes String as a value.
aggregateVerifier?The aggregate verifier obtained from the Web3Auth Dashboard. It takes String as a value.

Usage

Future<SFAKey> connect() {
return _singleFactorAuthFlutterPlugin.connect(LoginParams(
verifier: 'YOUR_VERIFIER_NAME',
verifierId: 'YOUR_VERIFIER_ID',
idToken: 'YOUR_ID_TOKEN',
),
);
}

Session Management

We have included Session Management in this SDK, so calling the initialize function to get the SFAKey value without re-logging in the user if a user has an active session will return the SFAKey, otherwise, it will throw an error.

Usage

try {
final SFAKey? torusKey = await _singleFactorAuthFlutterPlugin.initialize();
} catch (e) {
// Handle error
}