> For the complete documentation index, see [llms.txt](/llms.txt).

# Sign in a user

To sign in a user, use the `connectTo` method. It triggers the sign-in flow and opens a browser modal where the user can authenticate. Pass supported auth connections to `connectTo` for specific social sign-in providers such as GOOGLE, APPLE, and FACEBOOK, or use whitelabel sign-in.

## Parameters

The `connectTo` method takes `LoginParams` as a required input.

**Table**

| Parameter                  | Description                                                                                                                                                                                                                                                                                                                                                                           |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `authConnection`           | It sets the OAuth sign-in method to be used. You can use any of the supported values are `GOOGLE`, `FACEBOOK`, `REDDIT`, `DISCORD`, `TWITCH`, `APPLE`, `LINE`, `GITHUB`, `KAKAO`, `LINKEDIN`, `TWITTER`, `WEIBO`, `WECHAT`, `EMAIL_PASSWORDLESS`, `CUSTOM`, `SMS_PASSWORDLESS`, and `FARCASTER`.                                                                                      |
| `authConnectionId?`        | The connection ID for custom authentication. This is optional for social sign-in providers but required for custom JWT-based authentication.                                                                                                                                                                                                                                          |
| `groupedAuthConnectionId?` | Used for aggregate verifiers. When multiple auth connections are grouped under a single verifier, this specifies the aggregate verifier ID.                                                                                                                                                                                                                                           |
| `loginHint?`               | Provides a hint for the sign-in process. For email passwordless, this should be the email address. For SMS passwordless, this should be the phone number.                                                                                                                                                                                                                             |
| `idToken?`                 | JWT token for SFA (Single Factor Auth) sign-in. When provided, sign-in uses SFA mode.                                                                                                                                                                                                                                                                                                 |
| `extraLoginOptions?`       | It can be used to set the OAuth sign-in options for corresponding `authConnection`. Default value for the field is `null`, and it accepts `ExtraLoginOptions` as a value.                                                                                                                                                                                                             |
| `appState?`                | It can be used to keep track of the app state when user will be redirected to app after sign-in. Default is `null`, and accepts `String` as a value.                                                                                                                                                                                                                                  |
| `mfaLevel?`                | Customize the MFA screen shown to the user during OAuth authentication. Default value for field is `MFALevel.DEFAULT`, which shows MFA screen every third sign-in. It accepts `MFALevel` as a value.                                                                                                                                                                                  |
| `dappShare?`               | Custom verifier sign-in can return a dapp share after successful authentication. This is useful if the dapps want to use this share to allow users to sign in seamlessly. It accepts `String` as a value.                                                                                                                                                                             |
| `curve?`                   | It will be used to determine the public key encoded in the jwt token which returned in `getUserInfo` function after the user signs in. This parameter won't change format of private key returned by Web3Auth. Private key returned by `getPrivateKey` is always secp256k1. To get the ed25519 key you can use `getEd25519PrivateKey` method. The default value is `Curve.SECP256K1`. |
| `dappUrl?`                 | URL of the dapp. This is used for analytics and debugging purposes.                                                                                                                                                                                                                                                                                                                   |

**Class**

```kotlin
data class LoginParams(
    val authConnection: AuthConnection,
    val authConnectionId: String? = null,
    val groupedAuthConnectionId: String? = null,
    val appState: String? = null,
    val mfaLevel: MFALevel? = null,
    val extraLoginOptions: ExtraLoginOptions? = null,
    var dappShare: String? = null,
    val curve: Curve? = Curve.SECP256K1,
    var dappUrl: String? = null,
    var loginHint: String? = null,
    val idToken: String? = null,
)

enum class AuthConnection {
    @SerializedName("google")
    GOOGLE,
    @SerializedName("facebook")
    FACEBOOK,
    @SerializedName("reddit")
    REDDIT,
    @SerializedName("discord")
    DISCORD,
    @SerializedName("twitch")
    TWITCH,
    @SerializedName("apple")
    APPLE,
    @SerializedName("line")
    LINE,
    @SerializedName("github")
    GITHUB,
    @SerializedName("kakao")
    KAKAO,
    @SerializedName("linkedin")
    LINKEDIN,
    @SerializedName("twitter")
    TWITTER,
    @SerializedName("weibo")
    WEIBO,
    @SerializedName("wechat")
    WECHAT,
    @SerializedName("email_passwordless")
    EMAIL_PASSWORDLESS,
    @SerializedName("custom")
    CUSTOM, //for jwt
    @SerializedName("sms_passwordless")
    SMS_PASSWORDLESS,
    @SerializedName("farcaster")
    FARCASTER
}

```

## Return Value: `Web3AuthResponse`

`connectTo` returns a `CompletableFuture<Web3AuthResponse>`. The response contains:

| Field                   | Type            | Description                                                                                                        |
| ----------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------ |
| `privateKey`            | `String?`       | secp256k1 private key (EVM). Use `getPrivateKey()` for safe retrieval.                                             |
| `ed25519PrivKey`        | `String?`       | Ed25519 private key (Solana, Near, etc.). Use `getEd25519PrivateKey()` for safe retrieval.                         |
| `userInfo`              | `UserInfo?`     | User profile information. See [getUserInfo](/embedded-wallets/sdk/android/usage/get-user-info/) for field details. |
| `coreKitKey`            | `String?`       | SFA key returned when `useSFAKey = true`.                                                                          |
| `coreKitEd25519PrivKey` | `String?`       | SFA Ed25519 key returned when `useSFAKey = true`.                                                                  |
| `factorKey`             | `String?`       | Factor key for MFA flows.                                                                                          |
| `sessionId`             | `String?`       | Current session identifier.                                                                                        |
| `signatures`            | `List<String>?` | Session token signatures for advanced use cases.                                                                   |
| `error`                 | `String?`       | Non-null when the session returned an error.                                                                       |

Prefer the typed methods `getPrivateKey()` and `getEd25519PrivateKey()` over reading `privateKey` directly; they correctly handle the `useSFAKey` flag and throw `IllegalStateException` instead of returning null when no key is available.

## Usage

```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

val web3Auth = Web3Auth(
  Web3AuthOptions(
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
    web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
    redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
  ),
  this
)

val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
    LoginParams(AuthConnection.GOOGLE)
)

```

## Examples

**Google**

```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

val web3Auth = Web3Auth(
  Web3AuthOptions(
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
    web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
    redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
  ),
  this
)

val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
    LoginParams(AuthConnection.GOOGLE)
)

```

**Facebook**

```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

val web3Auth = Web3Auth(
  Web3AuthOptions(
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
    web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
    redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
  ),
  this
)

val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
    LoginParams(AuthConnection.FACEBOOK)
)

```

**Discord**

```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

val web3Auth = Web3Auth(
  Web3AuthOptions(
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
    web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
    redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
  ),
  this
)

val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
    LoginParams(AuthConnection.DISCORD)
)

```

**Twitch**

```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

val web3Auth = Web3Auth(
  Web3AuthOptions(
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
    web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
    redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
  ),
  this
)

val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
    LoginParams(AuthConnection.TWITCH)
)

```

**Email Passwordless**

```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

val web3Auth = Web3Auth(
  Web3AuthOptions(
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
    web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
    redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
  ),
  this
)

val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
    LoginParams(
        AuthConnection.EMAIL_PASSWORDLESS,
        loginHint = "hello@web3auth.io"
    )
)

```

**SMS Passwordless**

```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

val web3Auth = Web3Auth(
  Web3AuthOptions(
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
    web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
    redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
  ),
  this
)

val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
    LoginParams(
        AuthConnection.SMS_PASSWORDLESS,
        loginHint = "+91-9911223344"
    )
)

```

**Farcaster**

```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

val web3Auth = Web3Auth(
  Web3AuthOptions(
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
    web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
    redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
  ),
  this
)

val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
  LoginParams(AuthConnection.FARCASTER)
)

```

**JWT**

Usage

```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

val web3Auth = Web3Auth(
  Web3AuthOptions(
    clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
    web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
    redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
  ),
  this
)

val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
    LoginParams(
        AuthConnection.CUSTOM,
        authConnectionId = "your_auth_connection_id",
        idToken = "your_jwt_token"
    )
)

```
