For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

Sign in a user

To sign in a user, use the connectTo method. It triggers the sign-in flow and opens an in-app browser so the user can authenticate with the selected provider. Pass supported AuthConnection values for social logins (such as Google, Apple, Facebook) or custom JWT connections.

Parameters

The connectTo method takes LoginParams as a required input.

ParameterDescription
authConnectionSets the OAuth sign-in method to use. Supported values include google, facebook, reddit, discord, twitch, apple, line, github, kakao, linkedin, twitter, email_passwordless, custom, sms_passwordless, email_password, and farcaster.
authConnectionId?Auth connection ID from the Embedded Wallets dashboard. Required for custom connections.
groupedAuthConnectionId?Grouped auth connection ID for aggregate connections.
extraLoginOptions?OAuth options for the corresponding authConnection. For example, pass the user's email address as login_hint for email_passwordless. Defaults to null.
appState?Tracks app state when the user returns after sign-in. Defaults to null.
mfaLevel?Customizes the MFA screen during OAuth authentication. Defaults to MFALevel.DEFAULT, which shows MFA every third sign-in.
dappShare?Custom connection logins can return a dapp share after successful sign-in. Useful if your dapp uses this share to let users sign in without repeating the full flow.
curve?Determines the public key encoded in the JWT returned by getUserInfo. Does not change the private key format from Web3Auth. getPrivateKey always returns secp256k1. Use getEd25519PrivateKey for ed25519. Defaults to Curve.secp256k1.
idToken?JWT (ID token) for custom connections. Pass Firebase, Auth0, or other provider tokens here instead of extraLoginOptions.id_token.
loginHint?Optional login hint (for example, email or phone number) passed directly on LoginParams.

Usage

final Web3AuthResponse response = await Web3AuthFlutter.connectTo(
LoginParams(authConnection: AuthConnection.google),
);

Examples

Usage
Future<void> initWeb3Auth() async {
late final String redirectUrl;

if (Platform.isAndroid) {
redirectUrl = 'w3a://com.example.w3aflutter';
} else if (Platform.isIOS) {
redirectUrl = 'com.example.w3aflutter://auth';
} else {
throw UnKnownException('Unknown platform');
}

await Web3AuthFlutter.init(Web3AuthOptions(
clientId: "WEB3AUTH_CLIENT_ID",
web3AuthNetwork: Web3AuthNetwork.sapphire_mainnet,
redirectUrl: redirectUrl,
));

await Web3AuthFlutter.initialize();
}

// Sign in
final Web3AuthResponse response = await Web3AuthFlutter.connectTo(
LoginParams(authConnection: AuthConnection.google),
);